runAction(_:forKey:completionHandler:)
Adds an identifiable action to the list of actions executed by the node. SceneKit calls the specified block when the action completes.
Declaration
func runAction(_ action: SCNAction, forKey key: String?, completionHandler block: (@Sendable () -> Void)? = nil)func runAction(_ action: SCNAction, forKey key: String?) asyncParameters
- action:
The action to be performed.
- key:
A unique key used to identify the action.
- block:
A completion block called when the action completes.
Discussion
This method is identical to runAction(_:completionHandler:), but the action is stored and identified so that you can retrieve or cancel it later. If an action using the same key is already running, SceneKit removes it before adding the new action.
SceneKit calls your block after the action’s duration is complete. For example, you can use this method with a wait action to execute some code after a timed delay. If during the delay period you need to prevent the code from running, use the removeAction(forKey:) method to cancel it.