Is there a way to get a a part of an animated object to appear and play at a specific keyframe ?

I’m really not good in scripting and still not really familiar with Unity. I’ve tried researching if there is a solution but i don’t seem to find any somehow.

I have my objects animated in C4D and exported it to Unity to do AR and let the animation play in AR mode. There’s 2 objects that will appear at a diff timing when the whole animation is being played. I’ve created a script under the object that is going to come in at a later timing and i only know how to hide it at the start of the animation but i don’t know how to make it reappear at a certain keyframe time that i want. Is there an easy way to code for it to re-appear at that specific timing and hide the other object?
i’ve uploaded the actual animation and also a screenshot of the script i’ve been stucked on :frowning:


6071415--658314--Computer-animation-5.gif

Perhaps Animation Events would help. You add those to an animation on a certain frame. When this frame is reached, a method on the object can be fired.

You could also copy all the keyframes into a new animation, so you can add keyframes for the two underlying objects and simply animate their Enabled property.

thank you for replying. Do you mean i have to open my timeline first? I’m not sure where to see all the keyframes of my animation in unity, sorryy :face_with_spiral_eyes:

Yes, you have to open the timeline. At the top of any timeline there’s a grey bar on which you can add said Animation Events.

Animations from a file might be read-only. So you select all keyframes and ctrl-c, ctrl-v them into a new animation to open it up for modification.

Example: I did so with a Punch animation. First I copied over all keyframes so I could tweak the animation’s length. I then added two Animation Events at the start and beginning of the ‘contact’ frames.

The first enables a collider. The second disables it again. Use Animation Events for ‘run this method at this frame’ type of logic.

I could have also animated the Enabled property of said collider, or it’s position. It depends a bit on the needs of your game.

1 Like