- Home /
How to add a GameObject to an animation track in Timeline programmaticly?
I need to animate an object that is being instantiated. I am unable to to add it to Timeline since it requires me to drag it from the hierarchy, but its not there until the game starts.
Answer by sh_code · Jan 20, 2019 at 10:59 PM
how exactly do you need to animate it? as in, within the scene, or some other object, animate its transform (rotation and position)? or, animate the children of the instantiated object itself? (think a guy model with bones, you need to do animations for the bones).
if it's the first, make an empty transform in the hierarchy where the instantiated object should start, animate rotation and position of that transform, and then, at runtime, instantiate your object as a child of that empty animated transform.
if it's the second, just pull the object out to the scene, animate to your heart's content, then just delete it from the scene when done. when you instantiate the object, and tell it to play the animations you made, everything's going to work.
also, next time try to ask in a better way, so that people don't have to guess what you mean? ;)