Jump to content

[Question] Multiple colliders for hallow part (cargo bay)


Recommended Posts

Simple question:

I understand that to create a contained cargo bay-type part, you have to use multiple primitive collider objects to encapsulate the interior of the cargo bay. I'm currently working on a part and before I get too far, I want to know the best way to position these colliders: How close can they be positioned? Can they overlap? should I leave a very small gap in between the colliders? Any guidance will be appreciated!

Link to comment
Share on other sites

A bit of advice - you don't need LOTS of collider meshes for hollow parts - you need just few.

Unity mesh collider (without convex, so it's BLUE in Unity) does not collide with planet surface in KSP, but DOES collide with parts being surface-attached. Surface attachments - is what you usually want from hollow parts, no? So use it on your mesh or substitute low-poly and thrive with smooth part placement. That's step 1.

Step 2 is deciding if your part will ever touch the ground or collide anything. If not, you may skip step 3, blue mesh collider will work fine for you.

If yes... then step 3 - you'll need some "more physical" - GREEN Unity colliders. Those are box, capsule, mesh-with-convex and sphere... Add those exactly where you expect possible terrain collisions and skip the rest.

Look at my mod's LTS core tank. Mesh is pretty much hollow. And I use only 2 small box colliders at top and bottom to prevent land-sinking. Nay... I lied. It's 3 physicals. Unity "capsule" collider I used for central tank, as it's easier for game engine then mesh collider.

Also look at my Rugged Rover which have side hollows. Just 1 mesh collider (without convex) for all part-placing needs, 1 low-poly convex and 2 box colliders (for lids).

Or RTG Rover - it has a single green physical - box collider for central... box. Why nothing on sides? Because attached wheels and RTGs will collide with terrain instead and... tiny enough physicals will still land-sink.

Edited by Dr. Jet
Link to comment
Share on other sites

You can use the mesh collider in unity without checking the Convex box for a non-convex mesh (like your cargo bay). The only rule is that it must be a sealed object. This is that there are no holes in your mesh. I got caught by this when I did my stanford torus because I was trying to cut out polygons that would normally be invisible. Turns out this is worse for KSP than if I didn't remove the polygons, even though it should make sense from a stand point of model efficiency. KSP calculates the mesh tensor when you don't use the convex hull mode on the collider and if it finds holes it can't calculate the tensor. This can lead to models loading physics poorly and in some cases the ship blowing up because the physics glitched.

For your model:

- Split the end caps of your cargo bay into separate model components. You can apply a convex hull to each of the components separately in Unity. This will let your model impact terrain correctly in KSP. Yes. You need convex hulls to hit terrain without going through it.

- The rest of the cargo bay hull uses the mesh collider without the convex hull. This will satisfy your cargo bay interior requirement. You can separate the doors and animate the physics for them.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...