- Home /
Strange behavior of RigidBody2D
I'm trying to program a variation of the classic PacMan (partially following this tutorial: http://noobtuts.com/unity/2d-pacman-game).
I included my pacman GameObject, adding a Rigidbody2D. However, the rigidbody seems to be automatically moving to a aleatory direction. After a while, pacman gets stuck and cannot move anymore:
This is how I tryed to implement the movement (inside FixedUpdate method):
Vector2 p = Vector2.MoveTowards (transform.position, dest, speed);
GetComponent<Rigidbody2D> ().MovePosition (p);
Where "dest" is the destination of the movement. p is correctly calculated, but the rigidbody does not obey the movement defined by "p".
If I change the rigidbody settings to "Is Kenematic", I can control pacman movements correctly, however, the colisions do not work.
This is how the rigidbody is configured:
Any ideia on how to solve this and enable the movements with all colisions working?