- Home /
Unity 2d > Player sprite jerks on x axis with no force applied
Hi, This is my first unity project, it is almost complete. I have a bug which i noticed only a few days ago.
The player is a sprite with rigidbody2d and 3 colliders, it falls from the middle of the screen until it collides with the ground. The ground is a sprite with box collider2d with no rigid body. The camera is not moving - ortho.
I have enemies advancing from the right and pushing the player to the left. almost every time i start the level (but not every time) the player make a small jump (glitch) a few pixels to the right. before any sprite approached him, or any force applied to him.
I would put any code here which helps, but i don't know where to begin looking. please if this sounds familiar to anyone i appreciate any help.
Another glitch which might be related: the sprite changes animation with animator controller state machine once touching the ground (animator trigger). every once in a while the sprite transitions to the touch ground animation, without being close to the ground. I suspect some unseen collider but cannot find anything.
Thanks!
Answer by agora · Jun 23, 2014 at 01:17 PM
I found the answer after a few days, if any new user makes this same mistake and finds this answer, hope it helps:
My main character has a rigidbody2d attached to it, but the physics calculations were done on update(); once i moved the addforce to FixedUpdate() all glitches were solved.
this is the method i used: http://gamedev.stackexchange.com/questions/73713/update-vs-fixedupdate-in-unity
Am the one who had the same problem but now its got solved... Thanks a lot!!!!
Your answer
Follow this Question
Related Questions
2d rigidbody falling from the collider when it is moved 3 Answers
"Failed to update Unity Web Player" 0 Answers
2D Physics based rotation looses precision after hours 0 Answers
Moving colliders that are part of a composite collider 1 Answer
Making 2D objects solid, so that they do not pass through eachother? 1 Answer