SetEntityEnabledAction
An action that enables or disables the targeted entity and its descendants when played as an animation.
Declaration
struct SetEntityEnabledActionOverview
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)