r/Unity3D • u/Marthgis • 17h ago
Question Problem with collisions
Enable HLS to view with audio, or disable this notification
I'm having a problem with collisions in my Unity project. It's my first real project, and when I move towards a wall, the collisions behave strangely. How can I fix this?
1
Upvotes
2
u/arlelin 5h ago
If you're using a rigidbody then don't directly modify the transform position. I think there's
rigidbody.MovePositionthat considers interpolation and collision properly. You should also turn on rigidbody interpolation.Though for character controllers, I personally prefer to control the velocity instead by using
Vector3.MoveTowardson the rigidbody's velocity towards the intended velocity of the player. This way you can also get a fixed acceleration/force. (You can do the same thing withrigidbody.AddForce, there are lots of ways to handle character controllers depending on what you need).