- Home /
Could I move animated game objects as I want?
I make a game object and I add an animation to it. This animation has position (0,0,0) on 0 second, and (0,2,0) on 0.5 second and (0,0,0) on 1seocnd. (up and down animation)
I add an script to this game object that has code as follows.
this.GetComponent ().velocity = new Vector2 (-1*moveSpeed, 0);
I want to move my object toward -X axis and also I want my game object to move as it was animated.
As a result, my object doesn't move toward -X axis, and just follow as it was animated.
Is there any solution that can move animated game objects(which I animate its position) as I want?
It would be really glad if you help me. Have a nice day.
Answer by tormentoarmagedoom · Jan 24, 2019 at 03:25 PM
Good day.
First, you are doing GetComponent () without specify what component you want to get... Get component is to reach one of the components of the object... the animator maybe?
GetComponent<Animator>()
And then, you want to change the speed of the animation? not the velocity? velocity is a vector, speed is a integrer.
I think you are missunderstanding things. You should watch some tutorial about Animation.
Bye!
Your answer
Follow this Question
Related Questions
How to calculate the speed at which a rigidbody2d is actually moving ? 1 Answer
Character Joints and Animations results in strange physic animation 1 Answer
Mecanim additive animation sends characters flying? 1 Answer
calculate velocity of animated parent rigidbody from script inside child 2 Answers