Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Non Convex Mesh Collider

Hello guys,

Recently picked up game dev as a hobby so i started learning things bit by bit with all the tutorials and guide i could find on the internet, somehow ended up here looking to receive some advice from you guys.

My goal for the moment is that i want to make a 3rd person view with a detailed character collider (3D). So far I'm done with the camera using cinemachine and some basic movements scripts, then i wanted to add an actual graphics for my Player Character using the RPG assets from here.

My problem for now is this ...

As the error shown in the image, i can't use non convex mesh colliders (NCMC) with a non kinematic rigidbody.

To my understanding is that NCMC is more detailed, I need this particularly for my Player Characters and most likely for my Enemy characters but with the rigidbody set as kinematic i can't apply any physics related effect on it.

I had tried applying codes (solutions from the internet) that should have generated small colliders to encompass the shape but sadly didn't work. As i don't have a CS degree level of understanding complex algorithms, I'm kinda afraid I've had hit a wall already. 😞

If someone could point me to a right direction or shed some light on this matter it would be so helpful, thank you.

Answers

  • Convex means that the mesh never curves back into itself. Detail is not a part of the definition, but performance is what the error is about.

    A good way to think about it, is to imagine shining a light on the model. If it can cast a shadow on itself, like a crescent shape would, it is non-convex (concave may be a better term to use) . If the mesh can't cast any shadows, like a half circle, it is convex.

    And that's why unity doesn't allow NCMC with dynamic rigidbodies. It is much cheaper to calculate NCMC collisions, so unless you sacrifice calculations from the rigidbody, the performance is made up here.


    As far as fixing it, unless you are generating the meshes at runtime, not much to be done in terms of code. Most of the time in situations like this, character colliders are made up of multiple capsule colliders. Like 3 for each leg. This is vary performance friendly BTW as capsule colliders are the 2nd cheapest to calculate.


    Side Note: You mentioned not being able to apply physics to kinematic bodies. That is correct, kinematic means that these are physics objects, but not affected by physics.

    i.e. the wall can bounce the ball off it, but cannot be moved by it, is a good use for kinematic. Especially if you want the wall to be moved with code or animations.

Sign In or Register to comment.