---
title: SetEntityEnabledAction
framework: realitykit
role: symbol
role_heading: Structure
path: realitykit/setentityenabledaction
---

# SetEntityEnabledAction

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

## Declaration

```swift
struct SetEntityEnabledAction
```

## Overview

Overview This action toggles the targetEntity 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. // 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) 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 BindTarget.transform. tip: This action performs instantaneously, consider supplying a small positive duration value when creating the animation.

## Topics

### Initializers

- [init(targetEntity:isEnabled:)](realitykit/setentityenabledaction/init(targetentity:isenabled:).md)

### Instance Properties

- [animatedValueType](realitykit/setentityenabledaction/animatedvaluetype.md)
- [isEnabled](realitykit/setentityenabledaction/isenabled.md)
- [targetEntity](realitykit/setentityenabledaction/targetentity.md)

## Relationships

### Conforms To

- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [EntityAction](realitykit/entityaction.md)

## See Also

### Built-in actions

- [BillboardAction](realitykit/billboardaction.md)
- [EmphasizeAction](realitykit/emphasizeaction.md)
- [FromToByAction](realitykit/fromtobyaction.md)
- [ImpulseAction](realitykit/impulseaction.md)
- [OrbitEntityAction](realitykit/orbitentityaction.md)
- [PlayAnimationAction](realitykit/playanimationaction.md)
- [PlayAudioAction](realitykit/playaudioaction.md)
- [SpinAction](realitykit/spinaction.md)
