- Home /
How do you make an animation start from a location dynamically?
So far I have it set up so that when the player hits a collider trigger placed at the end of a course a "Goal camera" is enabled and it was set up to look at the target at the end of course before it was hit. It's position changes to follow the position of an empty Game object which has an animation attached to it so the camera snaps to the empty objects position and moves along the animation path.
My main problem is how can I get the empty object (Which I will now call camera helper) to start its animation from the point that the player hits and then move to the location of the animations path and then play the animations path. I was thinking about using a Lerp but thats all I can think of... I'm still working on figuring out what everything does its a bit overwhelming occasionally haha.
The steps so far: - player has a camera follow them to the end of course - player hits a collider trigger - the trigger is supposed to turn on a secondary camera -that camera is supposed to start from the players position and then move to follow the path of a preset animation.
Any advice so far?
Answer by runevision · Feb 26, 2010 at 03:20 PM
When you animate a position of a GameObject, it is actually the local position you are animating, not the global position.
Make a new GameObject and make CameraHelper a child of that. Now move the position of the parent GameObject before you start the animation of CameraHelper. It will play the animation relative to the position of the parent GameObject.
Oh wow thats a really good idea, Thank you very much for your help!
Alright that works but now I want to set the location of the new game object to be equal to the point of contact at the time the game object hit the box collider.
$$anonymous$$inda like (for Example) if I cross a finnish line the camera animation will start from the exact point that I crossed the line.
Okay I got it to work, Thank you very much now I can move on to other parts of the process.
Answer by gitsU · Mar 19 at 08:52 AM
I know It is literally more than 12 years later, but this reply saved me from doing some really complicated script animation, thank you so much