Hi, my player gets stuck into an object when it collides with it. The player has a rigidbody and the object only has a box collider. Please help me because I’m new to unity and I’ve been stuck on this for weeks.
(Here is the script attached to the player)
In this case, don’t use transform.position
to move an object which has Rigidbody. An object having Rigidbody being moved using transform methods will confuse the unity physics. Use methods of Rigidbody.
I believe Rigidbody.MovePosition will solve your issue. Look in to its official documentation to see how to use it. This method ensures that when an object collides with another object, it will not pass through it or get stuck in it.
I hope it helps.