Trying to simply play this animation... Help please.

I am using the FPS Controller that comes with Unity. When i press P i want my player to do the “Test” animation which moves it up into the air a litte, basically a jump animation. Whenever i press P it clamps my player to the position that the animation was recorded, it isn’t relative to where ever i may move. Why isn’t this working? Here is my simple script:

function Update () {

if (Input.GetKey("p"))
	animation.CrossFade("Test");

}

Please include a question if you want an answer.

–

...Why isn't it playing relative to the position?

–

1 Answer

1

@inglipX,

I’ll answer your question this time, but this is a question that should be rejected. With a google search it took me less than 3 seconds to find an answer.

You want a relative animation in unity? Google ‘unity relative animation’

First result: Relative animation? - Questions & Answers - Unity Discussions

I have googled that plenty of times and I have seen that thread in particular. Nobody has ever explained how to implement it.

–

I have tried make a parent of my player with an animation. Still doesn't work. I don't understand how to play the animation at any location. I have looked at those but i just don't understand; i'm not an advanced coder at all.....

–

Alright, I'll try to explain it a different way: Before you animate, put the thing you want to animate under another game object, as a child. Then, make your animation. Only move the child. Don't move the parent. When you move the child, it changes the transform position of the child, and the transform position of a child is always relative to the parent. Then, when you're done recording, you can move the parent anywhere, and the child will animate relative to the parent.

–

Okay i will try this, but is the animation of the child on the parent? Or am i just animating the parent?

–

You're not animating the parent at all - that's the key that makes this work.

–