Jump to content

Collider issues...


Recommended Posts

So I am having issues with non Convex mesh colliders. For some reason they are not working with my new dragon parts. The collider system is set exactly the same as the trunk for my Dragon V2 but for some reason it won't work for this trunk? Does anyone have any ideas what is going on and how to fix it?

Ow1Wg24.png

g8xxvAG.png

Edited by tygoo7
Link to comment
Share on other sites

For the tapered ring from my FusTek Station Parts, I made up 24 wedge-shaped meshes arranged in a circle in Blender, and set them as convex in Unity.

Once loaded in-game, my tapered ring would not fall through the launchpad surface, but a Kerbal could pass through the hole in the center unimpeded.

Link to comment
Share on other sites

For the tapered ring from my FusTek Station Parts, I made up 24 wedge-shaped meshes arranged in a circle in Blender, and set them as convex in Unity.

Once loaded in-game, my tapered ring would not fall through the launchpad surface, but a Kerbal could pass through the hole in the center unimpeded.

What kind of impact would this technique have on performance?

Link to comment
Share on other sites

What kind of impact would this technique have on performance?

Primitive Unity colliders use little to none processing power. Convex mesh colliders can sometimes bring heavy slowdowns. When I was making a wraparound tank, which is in my signature, I used 4 convex colliders at first. My fps drastically dropped even when I was playing with the part in editor. After I replaced them with Unity box colliders the problem was gone.

Link to comment
Share on other sites

Even a box-shaped mesh collider will be more expensive than a unity box collider, and the more triangles your mesh collider has the more expensive it is.

The cheapest of the unity colliders is the sphere collider, followed by capsule collider. So those are a good choice for triggers like airlocks and ladders. Box colliders are a little bit more expensive but still much cheaper than the most primitive mesh colliders.

Try to approximate the shape with as little polies in the mesh collider as possible, those physics calculations are one of the biggest performance sinks in KSP.

Link to comment
Share on other sites

Thanks, y'all.

As a follow-on, what kind/shape collider would you use for e.g. a 1/4 height fuel tank? (cylinder 2.5 diameter by .5ish height) Does the collider make any difference about how you would attach other parts to it?

Link to comment
Share on other sites

Cylinders usually get a 12-sided cylinder mesh collider, as unfortunately there is no cylinder unity collider. This seems to be a good trade-off between performance and precision.

And yes, the colliders make all the difference in how other parts attach to it. As with the cylinder example, the 12 sided collider on a 24-sided mesh will let attached parts slightly sink into every 2nd egde of it, but thats hardly noticable. With an 8-sided collider it'll start to get more obvious. As a rule of thumb you could say with a collider that has half the amount of supporting loops than the rendered mesh you're on the safe side, and from there see if you can make any additional reduction in polycount that will not make it noticably inaccurate, e.g. flat areas or low angle curves can be reduced further. Set yourself a certain maximum of of how much deviation from the rendered mesh you allow. I also think its better to let the deviations go mainly inwards into the part than outward, slightly clipping attached parts is better than attaching them floating.

Link to comment
Share on other sites

Also, as a "best practice" sort of thing, if you want your fuel tanks to behave like the stock tanks, and match up nicely with them, here's what the stock tanks do:

The visible mesh is a 24-sided cylinder for 1.25m through 3.75m diameters (I forget what the 0.625m parts were, it's like 16 or 18 or something). This is oriented so that vertices (rather than faces) point along the cardinal (X,Z) axes.

The collider is a 12-sided cylinder, with the faces (not the vertices) facing the cardinal axes. This helps facilitate surface attachment with angle-snap, so that it's not trying to align a part to an edge on the collider, but rather a flat face.

Link to comment
Share on other sites

When creating a collider for a cylindrical tank, what would be performancewise more efficient:

A) a 12 sided cylindrical mesh collider

B) 6 overlapping rotated unity box colliders

Wow, that's a tough one. If the 6 overlapping colliders were boxes made as mesh colliders, then the single 12-sided cylinder would assuredly be better, performance-wise. But I don't know how many CPU cycles are saved with the Unity boxes.

Link to comment
Share on other sites

Wow, that's a tough one. If the 6 overlapping colliders were boxes made as mesh colliders, then the single 12-sided cylinder would assuredly be better, performance-wise. But I don't know how many CPU cycles are saved with the Unity boxes.

Thanks for confirming my suspicion, that this is unchartered terretory.

I did some tests with a 708 part monster with KerboKatz PhysicalTimeRatioViewer.

With 12-sided Mesh colliders I reached 30-31%

With 6 Unity Box colliders I reached 21-22%

So it seems like in this case Cylindrical Mesh colliders work faster.

However since I never made such a comparison before, I am not quite confident, if this measurement is reasonable.

Javascript is disabled. View full album

If someone wants to make some tests on their own, here is a zip containing the parts and ships: https://www.dropbox.com/s/n70awzxe3kcfy43/Colliders.zip?dl=0

Link to comment
Share on other sites

Thanks for confirming my suspicion, that this is unchartered terretory.

I did some tests with a 708 part monster with KerboKatz PhysicalTimeRatioViewer.

With 12-sided Mesh colliders I reached 30-31%

With 6 Unity Box colliders I reached 21-22%

So it seems like in this case Cylindrical Mesh colliders work faster.

However since I never made such a comparison before, I am not quite confident, if this measurement is reasonable.

http://imgur.com/a/Fmkh9

If someone wants to make some tests on their own, here is a zip containing the parts and ships: https://www.dropbox.com/s/n70awzxe3kcfy43/Colliders.zip?dl=0

thx for interesting results :) might be worth to test those in vacuum since for completeness :)

Link to comment
Share on other sites

  • 1 year later...
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...