- Home /
How can I get 'live' transform position of an object while it's animated?
I want to have a camera follow a moving object. I could move the object with a script, but I thought, why not just Animate it, right? Then have the camera follow that object, no problem.
Well, yes problem. When I animate the object and hit 'play' in the Animation window, I can see the Position x,y,z changing as I expect. But when I play the animation in the game, those values do NOT change, and my camera does NOT follow it.
This seems pretty basic. Why wouldn't those values change? And/or what am I doing wrong, or need to do?
Answer by IJM · Nov 17, 2010 at 10:05 PM
To do something like that you will need to follow a specific vertex in the mesh that is on your game object.
To get the posigion of the vertex you will need to do something like this:
Vector3 position = gameObject.GetComponent<MeshFilter>().mesh.vertices[SpecificVertex] + gameObject.transform.position;//SpecificVertex is any vertex from 0-vertices.Length
p.s. Try to set the vertex taht you will follow in to the center of the mesh. You can read it's number (SpecificVertex in this case) form your model editing tool.
Your answer
Follow this Question
Related Questions
Camera rotation around player while following. 6 Answers
GameObject follow animation 1 Answer
Following mouse 2 Answers
set child object position when playing the animation 0 Answers