My vehicle is driving through the wall but it should collide with it. My wall has 3011 verts and 5434 tris. Pls help my
When it come to collision there are several things I always check to ensure it has been set up properly.
- Collides are turned On. you know enable(in your screenshots they are)
- your rigid body is setup correctly, you’re already colliding with rocks so this isn’t an issue.
- your velocity isn’t exceedingly high, at very high speeds the engine can’t keep up and collision glitches occur. this why in some older racing games you hit a wall at top speed and sometimes you fly out into infinity.
- you rigid-boy is on the outside of the collider, if its on the inside which now entire possible because of the convex mesh collider, it will not work accurately, the green lines represent where you will hit.
- your not using a non-convex mesh collider with a rigibody. in your screen shot you are for that wall, I’m not entirely sure why you put a rigid body on that.
!!!DING DING DING!!!.
that’s it N.o 5 is your problem. your mesh collider will not work with a rigid body attached unless its convex. it works while convex but when you hit it it flies away(thats your rigide body in action)
your issue is likely the rigid body component on the wall. in the docs mesh collider doesn’t support being a rigid body unless it is convex. now for a big wall like that, i think the rigid body component be removed. once removed turn convex off for accurate collisions.
##Solution 2: Keep Rigidbody and use Box Colliders instead ##
for whatever reason you want a rigid body component on that wall(rigidbodies aren’t required for collision). set all the constraints to stop it flying away like it does when you made the mesh collider a convex one.
now for the long and tedious part. in you scree shot you can see how inaccurate convex mesh colliders are for weird shaped meshes like that big rock formation you have. to get around this id probably do away thew mesh collider altogether and set up a bunch of box colliders that follow the perimeter of your object. this way you can make the thing as accurate as you want.
That pretty much sums up your problem.
Hope it helps.