Objects with 0 bounce still bouncing

So I have this situation where I want to have objects represented by Axis-Aligned Bounding Boxes. The blue block is supposed to move along the floor block with a velocity and run into the wall and stop:

![alt text]

So I set up 2 platform objects with their motions constrained so they can’t move linearly or rotate. I have a running object that can’t rotate that moves with the WASD keys. They have physics materials so they don’t have any friction and they have a bounce of zero. Both have their bounce combine set to minimum.

I can get running object to run along the platform and hit the wall just fine. The problem is that after it hits the wall it bounces slightly in and start going back along the platform. I want it so the block just stop when it hits the wall (0 restitution). It should essentially hit the wall and stick but it only does that if I hold the move left button.

Is there any way in unity to control how contacts are resolved? I’ve made 2D physics engines before and I’m considering rolling my own for unity (which would take a while) if I can’t get this object to stop when it runs into the wall.

I don’t know the nature of your game, but here are a few ideas of how you might work around your issue:

  • Turning on the Rigidbody.isKinematic flag in the OnCollisionEnter() and turning it off when you next want to add force.
  • Setting the Rigidbody.velocity and Rigidbody.angularVelocity to Vector3.zero in OnCollisionEnter() You may also want want to call Rigidbody.Sleep().
  • Use a CharacterController for movement rather than a Rigidbody.

If all you will ever do is move with no friction, never bounce and never rotate, it works just fine to run physics by hand (updating/applying your own speed variable.) Except OnCollision won’t fire if rigid bodies aren’t moving you, so use triggers (or ray casts?)

Could try giving it some static friction. No friction and “flat” surfaces can have odd sliding. Static “locks” non-moving objects but has no effect once you get moving.

But, sometimes you just have to “help along” physics in fixedUpdate. . Maybe kill very small sideways motion each frame (which will never naturally occur) : V = rigidbody.velocity; if(Mathf.Abs(V.x<0.1f)) { V.x=0; rigidbody.velocity=V; }

Or, set freezeX on a wall hit, unset on any other hit, and add if(freezeX) restore saved X pos