Negate a Single Collision

I’ve been digging through numerous questions regarding the default contact offsets for collisions and bouncing upon transferring between seamless, parallel colliders. However, reducing a safety buffer to be nearly nonexistent seems like a silly solution to a common problem, since it would only introduce other physics abnormalities.


Instead, I’ve started taking a look at whether the collisions occurring are reproducible on a regular basis. Well, they’re not.

// C#
void OnCollisionEnter(Collision other)
	Vector3 cNormal = other.contacts[0].normal;
	Vector3 hNormal = cNormal;
	RaycastHit hit;
	Ray ray = new Ray(transform.position, other.contacts[0].point - transform.position);
	if(other.collider.Raycast(ray, out hit, (other.contacts[0].point - transform.position).magnitude * 1.01f))
		hNormal = hit.normal;
		if(cNormal != hNormal)
			Debug.Log("unequal: " + cNormal.ToString("F5") + " --- " + hNormal.ToString("F5"));

In summary, what I’m testing is this:

  1. Get the normal of the collision upon transferring between colliders.

  2. Get the normal of a raycast fired toward the location of the collision

  3. Test whether the normals are the same. If they’re not, then I hit the rounded corner safety net. Otherwise, they were the same and I would not have bounced when transferring between them.

The problem, however, lies with dealing with this issue once I’ve found it.

One option is to set the Rigidbody’s current velocity vector to the previous frame’s value, but that doesn’t appear to actually prevent a bounce. As well, it would disrupt movement speed and result in the player being unable to change their velocity as clearly as they should.

Because the raycast won’t guarantee a hit on the top side of the object with 100% certainty, it would be foolish to assume that I can simply rely on trying to reset my velocity based on a tangent to the collision.

Physics.IgnoreCollision(gameObject.GetComponent<Collider>(), other.collider); doesn’t change the resulting velocity from the current collision, so that hasn’t helped anything.

Are there are reasonable means of preventing a collision from affecting velocity under these circumstances? Have I simply been taking the wrong approach in the first place? Any advice would be greatly appreciated!

I encountered this same problem in a recent build, I assume that your circle is moving quite quickly which is likely causing the issue (a slow moving fps wouldn’t run into this, only a fast moving racer).

The solution with the car came naturally with the use of a raycast suspension system, which means the car never really touched the road but simply hovered above it, looking like it was touching. So in your case, the circle could send out a raycast straight down every fixedupdate, and move the height to a point if it is below a certain threshold.

Otherwise, the most simple solution is to change the ground colliders into one collider (a procedurally generated collider perhaps?)