- Home /
The question is answered, right answer was accepted
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");
}
Answer by Julien-Lynge · May 01, 2013 at 09:37 PM
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: http://answers.unity3d.com/questions/10865/relative-animation.html#answer-10869
I have googled that plenty of times and I have seen that thread in particular. Nobody has ever explained how to implement it.
That's why you need to include context information in your questions, so we know what you've tried already and what exactly isn't working :)
That question does contain an answer with how to implement it:
"I had to put the object inside another GameObject (parent). Then I moved with GameObject ins$$anonymous$$d of the Button.
Peter"
"Yeah, ran into that one myself. Would be nice if this was better documented. I guess it happens because the animation can contain animated positions as well."
I take it that doesn't make sense to you? This one has how to implement it right in the question (second result in google search):
http://answers.unity3d.com/questions/352879/animations-relative-to-world-space.html
What about these don't you understand? $$anonymous$$aybe you can rephrase your question.
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?
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Animation Script Help 0 Answers
Reloading Help 2 Answers
Need help with some OnTrigger Scripting 2 Answers
what's wrong with this script? 2 Answers