- Home /
Stop object colliders (non-mesh) bouncing on collision
Hi,
I am trying to find a way to restrict the left / right movement of an object that is moving forward and following a curved path between two walls. I have tried using colliders on the walls and on the object but when they collide they tend to bounce.
As, this is a curve, I believe I cannot use Mathf.Clamp? So I have used a number of box colliders which have been rotated to form the shape of the curved walls. Please see image below.
I have heard mention that mesh colliders could be the answer, but am not keen to use them as they are usually not recommended for iOS games. Also, I would require a mesh which would be the shape of the curves below.
Any ideas would be great - Thanks.
Answer by Kryptos · Dec 11, 2012 at 03:01 PM
Bouncing can be set/unset by using a dedicated PhysicsMaterial. See the bounciness property.
And I recommend using a MeshCollider instead of the built-in BoxCollider. You can create a mesh procedurally to follow your curve (using mesh strips, this should not be very difficult).
I used a similar system in my car game:
I had a set of waypoints.
I generated a curve based on these waypoints.
I had three set of mesh and colliders that cycled along the path, generating the corresponding vertices on the fly.
And I used Physics Material of these mesh colliders to properly set their properties (especially bounciness).