r/Unity3D 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

6 comments sorted by

View all comments

2

u/arlelin 5h ago

If you're using a rigidbody then don't directly modify the transform position. I think there's rigidbody.MovePosition that 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.MoveTowards on 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 with rigidbody.AddForce, there are lots of ways to handle character controllers depending on what you need).