- Home /
Change Animation Position When I Press Button
Hello Unity3D i have a question about animation positions?.How can i make it that whenever i play an animation my 3d animation moves forward like 3 steps?For example.Whenever i press the punch key my character does the punch animation but stick in the same spot.What i want is that whenever i click the punch key the punching animation moves for 3 steps.If anyone knows how i can do this.Can you please tell me how?
Answer by Qasem2014 · Dec 30, 2014 at 06:43 PM
1 - why you write your question like code ? edit it :D
2 - you should put your character in another (empty) game object ! then modify your code like this :
if user press punch key do the animation and do this on your empty game object :
emptygo.GetComponent.<Rigidbody>().velocity = emptygo.transform.TransformDirection(Vector3(20 , 0 , 0));
this code make your character go ahead ! emptygo is your empty game object . its a variable of GameObject type :
var emptygo:GameObject;
please notice that you maybe should modify << Vector3(20 , 0 , 0) >> . search for it if you don't know whats this !
Sorry i dont know why it does that sometimes...D=.And im going to give this method a try right now =D
you select the text and click on 101010 button :D 101010 button make your text like codes :D
Thanks i fix that problem.But with your script my character moves tot he side i want it to move forward is there a way to do that?
change Vector3(20 , 0 , 0) to Vector3.forward !!
read this for vector 3 !
AND maybe you should add velocity force to character directly ! test your script for empty game object and character , both :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613175157im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Maya animations not playing in Unity 3 correctly 0 Answers
Using AnimationClip.SetCurve on child object. 0 Answers
Unity 4.5.2 bug changing the properties of the 2d colliders in animation 1 Answer
why does the animation looks different when imported into unity 2 Answers