- Home /
Player going through curved walls imported from blender
(I've tried all the solutions I could find on this forum with no result. See "What I Tried" for more details.)
The Issue: The car in my game is moving through walls on my racetrack. The best result still had the car bounce off the wall a few times, but suddenly clip into the wall at about 10 x Time.deltaTime (a slow speed). After troubleshooting I found that this is clearly an issue with using mesh colliders for the walls, but it would be literally impossible for me to convert my racetrack's walls to box colliders. How do I make curved walls for my racing game that the car will actually collide with?
The Setup: The car is a convex mesh collider with a rigidbody with Y position constraint frozen and XYZ rotation constraint frozen (This needs to be done for the type of movement I'm doing and works fine when I use boxes as the walls; setting all constraints off doesn't fix the issue). The walls of the road are a mesh collider and follow a smooth curve. All the faces are facing the right way. Using a straight plane as the road with box colliders as the walls, the collisions work perfectly (even when i change the box colliders to mesh colliders), so
the problem is using mesh colliders for walls with multiple faces as the car is clipping between the vertices.
The walls are made using boxes following a bezier curve in Blender. The car moves using transform.Translate on a FixedUpdate.
What I tried ([X] denotes steps that worked for the plane with two boxes setup) :
[X] Continuous collision checking
[X] Project Settings > Physics > Default Max Depenetration Velocity = 1000
DontGoThroughThings.cs
Continuous Dynamic/Continuous Speculative collision detection
Setting the player collider to a box/capsule collider
Switching car movement to rb.AddForce()
How I made the walls:
New Scene in blender
Make a bezier curve
Make a cube > Edit mode > Move it X units to the right
Add an array modifier and a curve modifier, set the length to fit curve, merge set to true on the array mod
Apply the array mod, apply the curve mod
Export as FBX, import to unity
Surely some Unity game out there uses curved walls this happening, so I'm open to learning about any pipelines for making racetracks with curved walls.
Answer by OsmosisJonesOverHeaven · Apr 06, 2021 at 02:01 AM
Troubleshooting update: I made a cube in blender and imported it, using a box collider and then a mesh collider. Worked perfectly. Then I loop cut the cube so it would have many faces all flat and facing the same direction. Box collider worked fine, but when i used the mesh collider, the car clipped through the cube when it hit one of the vertices where the faces met.