<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/SetEntityEnabledAction",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation22SetEntityEnabledActionV"
  },
  "title" : "SetEntityEnabledAction"
}
-->

# SetEntityEnabledAction

An action that enables or disables the targeted entity and its descendants when played as an animation.

```
struct SetEntityEnabledAction
```

## Overview

This action toggles the [`targetEntity`](/documentation/RealityKit/SetEntityEnabledAction/targetEntity) [`isEnabled`](/documentation/RealityKit/Entity/isEnabled) flag.
Use the animation generated from this action within an animation group to determine when the entity should be
enabled, and visible in the scene.

The example below creates an animation which disables the entity after five seconds.
In this example, the target entity starts enabled.

```swift
// Create an action entity resolution.
//
// The animation will be played from the parent entity.
let childEntity: ActionEntityResolution = .entityNamed("childEntity")

// Create an action to disable the entity.
let disableEntityAction = SetEntityEnabledAction(targetEntity: childEntity,
                                                 isEnabled: false)

// Create a small positive duration value.
let duration: TimeInterval = 1 / 30.0

// Create an animation to disable the target entity.
let disableEntityAnimation = try AnimationResource
    .makeActionAnimation(for: disableEntityAction,
                         duration: duration,
                         delay: 5.0)

// Play the sequence animation that plays the actions.
rootEntity.playAnimation(disableEntityAnimation)
```

![A screen recording of a red cube in a living room scene. At the start, the cube is visibly enabled in the scene. After some time, the cube is disabled; it's no longer visible in the scene.](videos/com.apple.RealityKit/setentityenabled-action.mp4)

> Note: Animations do not play on entities that are disabled. In order to disable, and enable the target entity,
> play this action on another entity, such as a root entity, or its parent.

> Important: This action does not animate a bound property, such as ``doc://com.apple.RealityKit/documentation/RealityKit/BindTarget/transform``.

> Tip: This action performs instantaneously, consider supplying a small positive duration value when creating the animation.

## Topics

### Initializers

[`init(targetEntity: ActionEntityResolution, isEnabled: Bool)`](/documentation/RealityKit/SetEntityEnabledAction/init(targetEntity:isEnabled:))

Creates a new set entity enabled action.

### Instance Properties

[`var animatedValueType: (any AnimatableData.Type)?`](/documentation/RealityKit/SetEntityEnabledAction/animatedValueType)

The type for the value that the action modifies over time.

[`var isEnabled: Bool`](/documentation/RealityKit/SetEntityEnabledAction/isEnabled)

A Boolean that you set to enable or disable the entity and its descendants.

[`var targetEntity: ActionEntityResolution`](/documentation/RealityKit/SetEntityEnabledAction/targetEntity)

The entity to disable or enable.

## Relationships

### Conforms To

[`Encodable`](/documentation/Swift/Encodable)

[`Decodable`](/documentation/Swift/Decodable)

[`EntityAction`](/documentation/RealityKit/EntityAction)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)