- Home /
Two objects on the same Y level bumping the player
Hello!
I made a simple test game where I have a Player cube sliding on rectangles, and I made a part with an intersection with two rectangles as shown on the image below :
and for some reason, depending on the Player's cube position, the cube might end up being bumped in the sky while sliding on this part.
To make the Player cube move forward I am using :
public float forwardForce = 8000f;
void FixedUpdate()
{
rb.AddForce(0, 0, forwardForce * Time.deltaTime);
}
The two rectangles are exactly on the same Y level. Any ideas why this is happening and how to fix it ?
I think Physic Material can be a good starting point. I didn't play with it much, but check it out the way it was described here and Unity also has documentation for it.
https://answers.unity.com/questions/752452/making-objects-slide.html
Probably you need to lower the friction between the player and the ground and it will solve this issue.
I think it is about box colliders. Making one of them is trigger would work.
Answer by ahsen35813 · Sep 05, 2021 at 03:04 PM
There is unfortuantely no known fix for this yet. This is a common annoyance to many game developers, and it happens quite frequently. If you build your own mesh (using something like Blender) which is a solid body instead of two separate intersecting cubes, this will not occur. I think something in the physics engine checks ahead of the rigidbody a little bit and then jumps up when it sees that there is an edge ahead, even though it shoudn't technically hit it. I may be wrong about this, perhaps there is a solution other than making a custom mesh but I don't know.