Jump to content

[Help] I am having trouble with making collision meshes.


jackkymoon

Recommended Posts

All of my parts up until now have used the physics mesh collider made in unity and that works fine, however I want to make my own custom collision mesh for a command pod. From what I understand it is possible to make a mesh in 3ds max and name it node_collider, then import that along with your model into unity. You would then tag that collider with "node_collider" in unity as well? I have done all of this but whenever I try to use this method the part doesn't show up.

Link to comment
Share on other sites

call the mesh whatever you want, just so you can identify it in Unity easier. I typically name the collision mesh with COL_ prefix. after import, add mesh collider component to the COL_ mesh; then delete its mesh filter and mesh renderer component. You generally want to make the mesh collider "Convex", or you'll be able to clip the object in some instances in KSP. You should see a green mesh outline in Unity if you've set up the collision mesh correctly.

Link to comment
Share on other sites

call the mesh whatever you want, just so you can identify it in Unity easier. I typically name the collision mesh with COL_ prefix. after import, add mesh collider component to the COL_ mesh; then delete its mesh filter and mesh renderer component. You generally want to make the mesh collider "Convex", or you'll be able to clip the object in some instances in KSP. You should see a green mesh outline in Unity if you've set up the collision mesh correctly.

I keep getting a "the hull has more than 255 polygons error, this is invalid" This occasionally happens to me but I have no idea what's going on.

Link to comment
Share on other sites

Its just a standard mesh you need, as simple as you can make it (and don't forget convex). In unity, remove the mesh renderer component, add a mesh collider component and tick the convex option. Ignore the names, doesn't seem to matter what you call it as long as the mesh collider physics component is added.

Link to comment
Share on other sites

Convex mesh collider must be 255 triangles or less. it will collide with everything else however. Non-convex mesh collider will not collide with another non-convex collider; so if you have two parts in the VAB or SPH, both have non-convex colliders, they will clip through each other regardless of your config file and debug menu settings.

Link to comment
Share on other sites

Convex mesh collider must be 255 triangles or less. it will collide with everything else however. Non-convex mesh collider will not collide with another non-convex collider; so if you have two parts in the VAB or SPH, both have non-convex colliders, they will clip through each other regardless of your config file and debug menu settings.

Thanks for the help guys I got it mostly figured out now! As far as convex goes I need this part to be concave and have a hole in the middle of it, but that's the only part That I need that way so it shouldn't be a big deal.

Link to comment
Share on other sites

Thanks for the help guys I got it mostly figured out now! As far as convex goes I need this part to be concave and have a hole in the middle of it, but that's the only part That I need that way so it shouldn't be a big deal.

For concave parts (such as rings), use multiple convex colliders - that is how I made the recessed ends of my tapered FusTek modules.

Link to comment
Share on other sites

  • 5 years later...
On 7/9/2014 at 6:00 PM, sumghai said:

For concave parts (such as rings), use multiple convex colliders - that is how I made the recessed ends of my tapered FusTek modules.

Sorry to necro this thread, but how does one accomplish this? I'm trying to make a docking port with a hole through the middle, and several pits along the top of the ring to make docking at specific angles easier.

Link to comment
Share on other sites

16 hours ago, Fireheart318 said:

Sorry to necro this thread, but how does one accomplish this? I'm trying to make a docking port with a hole through the middle,

Assuming your docking port is a 12 (or 24)-sided cylinder:

  • Perform a boolean operation with a smaller-diameter 12 (or 24) sided cylinder of the same height as your original cylinder, to cut out the ring
  • Next, split the cylinder into 12 (or 24 separate) wedge-like meshes
  • Each mesh should now be convex
16 hours ago, Fireheart318 said:

and several pits along the top of the ring to make docking at specific angles easier.

Consider also specifying the (optional) snapRotation and snapOffset parameters for ModuleDockingNode - here's an example from a very old version of my perpetually-delayed FusTek Station Parts mod:

MODULE
{
	name = ModuleDockingNode
    referenceAttachNode = top
    nodeType = FusTek_IACBM
    acquireForce = 0.5
    acquireRange = 0.01
    captureRange = 0.01
    captureMinRollDot = 0.99999
    snapRotation = true
    snapOffset = 90
}

 

Link to comment
Share on other sites

9 hours ago, sumghai said:

Assuming your docking port is a 12 (or 24)-sided cylinder:

  • Perform a boolean operation with a smaller-diameter 12 (or 24) sided cylinder of the same height as your original cylinder, to cut out the ring
  • Next, split the cylinder into 12 (or 24 separate) wedge-like meshes
  • Each mesh should now be convex

Should each segment be its own individual object, or just one object made of separate "blocks"? I'm using 3ds Max for modeling if it matters

Link to comment
Share on other sites

14 hours ago, Fireheart318 said:

Should each segment be its own individual object, or just one object made of separate "blocks"?

Each segment should be its own individual mesh / object, as that's the only way they will be treated separately when you set them as colliders in KSP Part Tools for Unity.

14 hours ago, Fireheart318 said:

I'm using 3ds Max for modeling if it matters

I don't know much about 3DS Max, since I (like most modders here) prefer to use Blender, as the tool chain leading to Unity and KSP Part Tools is somewhat more straightforward (despite its steep learning curve).

Most advice on these subforums will tend to apply to Blender anyway, as it's a free open-source software, and some enterprising modders have even written tools to make life easier for modders - for instance, taniwha's Blender .mu import/export plugin, which allows modders to examine stock meshes and textures, allowing them to make "stockalike" parts.

 

Link to comment
Share on other sites

  • 2 weeks later...
On 4/15/2020 at 7:33 AM, sumghai said:

Each segment should be its own individual mesh / object, as that's the only way they will be treated separately when you set them as colliders in KSP Part Tools for Unity.

Any idea why this isn't appearing in-game? I've also tried just applying the mesh to the 'meshatm2' object and not each individual part.

 

Link to comment
Share on other sites

@Fireheart318

 All the collider parts, that you correctly put Mesh Collider Convex on Inspector on each one, i recommend you remove the mesh renderer for each one of that, just because you don't want it to appear in game.

They are only colliders, not visible objects.

Mesh Renderer should be only on the 3d model that will appear on game.

And your Mesh Renderer object (meshatm2body) has no shader, no KSP shader on it. Look on Mesh Renderer, field Materials, that are set with size 1, and should be only 1 (KSP won't accept more than one shader for 3d part), the next field are Element 0. This one has noting on it. Is where you should put your shader.

The shader type i mostly use (no transparency) is KSP/Emissive/Bumped Specular (Mapped). I can have textures for Spec, RGB, Normal, Emissive.

For the transparent parts like glass i use KSP/Alpha/Translucent Specular. Using only an RGBA map.

Edited by Climberfx
Link to comment
Share on other sites

On 4/15/2020 at 7:33 AM, sumghai said:

Each segment should be its own individual mesh / object, as that's the only way they will be treated separately when you set them as colliders in KSP Part Tools for Unity.

Okay, I got the collisions and whatnot to work, but I can't get the ports to detach from each other when connected in the VAB, even though they work fine when you dock them in flight. There are also no staging options available. I'm assuming this has something to do with decouplers, but I can't find any documentation on how to do that, or even if that's actually how it works. Can I have some help, please?

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...