- Home /
Animator behaviour on GameObject
Hello,
I am completely new to unity/game development and stumbled on a small problem I can't figure out.
I have a GameObject and I applied a Sprite to it. I gave it 2 Collider's, circle & box as a tutorial, spaceship 2d from unity. I added a Script to it to let it move.
void FixedUpdate()
{
float move = Input.GetAxis("Horizontal");
rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);
}
Which moves the GameObject to left or right.
But when I add an Animator I can't move it anymore. Why does the Animator prevent the moment?
Also I noticed that when I added the Animator is that where I place the GameObject on the scene is not where the GameObject starts when I preview the game? I kind of teleports to the left side of the scene. Like It has a fixed position or something.
I tried using the Animator update mode 'Animate Physics' but then I will only move within a few pixels form itself.
Hopefully I am clear enough
Thanks in advance.
@tanoshimi I have these settings: http://s28.postimg.org/5qc3hwi4d/animator.png
Try baking movement in the import for the model.
You can 'override' Animator by either using LateUpdate or OnAnimator$$anonymous$$ove to perform movement.
Answer by toddisarockstar · Feb 20, 2015 at 04:47 AM
thats odd , the animator shouldnt override movement. i think I may have had this problem once though because 3dmax impored without a proper parent. the animator does contain positions for the objects and its children. maybe the animator is relating positions to world space. so here is how i fixed...
create a new empty game object. (if your new, click on the gameobject tab on the very top menu bar). Rename it as whatever name you want to call your object.
drag and drop your actuall object into the new empty. add your movement scripts to only the newly named empty which represents your object now.
if your animations are reasigning to world space, this would fix the problem. other than that.... there is no other reason why an animator would have anything to do with movement!
I hope this works for you.
btw... this technique works well for other weird fbx inport /export setting such as charaters importing upside down.
Your answer
Follow this Question
Related Questions
2D Animation does not start 1 Answer
Animator warning in editor, animation is preventing script from working 1 Answer
Animation Lag when Changing Movement Direction 2D (4.3) 2 Answers
SpriteManager 2 1 Answer
Best way to do animate soldier? 1 Answer