Animate RealityKit Component Property

Is it possible to animate some property on a RealityKit component? For example, the OpacityComponent has an opacity property that allows the opacity of the entities it's attached to, to be modified. I would like to animate the property so the entity fades in and out.

I've been looking at the animation API for RealityKit and it either assumes the animation is coming from a USDZ (which this is not), or it allows properties of entities themselves to be animated using a BindTarget. I'm not sure how either can be adapted to modify component properties?

Am I missing something?

Thanks

Answered by Graphics and Games Engineer in 777073022

There is currently no API in RealityKit to animate arbitrary component properties; feel free to file a feature request on http://feedbackassistant.apple.com. In the meantime, you can make a custom System that animates the properties with API calls.

Actually I see this is possible by binding to the Opacity BindTarget. But assume I have something other than an OpacityComponent - how would one target a property on a component?

Accepted Answer

There is currently no API in RealityKit to animate arbitrary component properties; feel free to file a feature request on http://feedbackassistant.apple.com. In the meantime, you can make a custom System that animates the properties with API calls.

For the case of opacity, this Entity extension provides setOpacity(_:animated:duration:delay:completion:) which lets you animate that property: https://gist.github.com/drewolbrich/1e9d3da074c8a1d5ca93721124b97596

It's implemented in terms of OpacityComponent and FromToByAnimation.

Animate RealityKit Component Property
 
 
Q