Jump to content

[SOLVED] Best practice for adding collision shape?


photo

Recommended Posts

Okay, so we have hi-polygons models and a low-polys ones for approximating collisions.

So I'm wondering, what's the best practice for using them into Unigine?

 

Here's my guess so far:

 

1. Add both high and low poly ones at the same place and parent them.

 

2. Turn off collision check box on the high poly ones

 

3. Set viewing mask on the  low-polys ones to be invisible.

 

So... am I doing this right? This seems very tedious compare to my experience though...

Does anyone have a different method? 

Link to comment

Hello Warit,

 

It depends on your requirements I suppose. For example, if your assets are mostly convex then it's better to use collision shapes instead of low-poly collision surfaces. In Oil Rush, we used collision surfaces for platforms and collision shapes for fx.

 

Also, you can just disable collision surface so it won't be visible.

Link to comment

Arrr ok... wish you could disable a surface and enable only its collision though.. setting up viewing mask is a lot of pain.

 

So in related topic, am I correct to say that splitting the collision into small zones and objects are better, since you seem to be checking for their bounding boxes first?

Link to comment

Hi!

 

Sorry for late reply. 

 

Arrr ok... wish you could disable a surface and enable only its collision though.. setting up viewing mask is a lot of pain.

 

You can! Just uncheck "enabled" flag on the collision surface. No need to setup view masks.

 

 

So in related topic, am I correct to say that splitting the collision into small zones and objects are better, since you seem to be checking for their bounding boxes first?

 

Physics engine in Unigine works like many other physics engines: it has broad phase and narrow phase. In broad phase it checks bounds first to determine possible collision pairs and then does shape intersection in narrow phase. So the worst case scenario in broadphase took O(N^2) (you'll need to compare all nodes with each other). That's unlikely but real. The more bounds you have the more time broadphase will take in the worst case. Also, bounds size affects how much other bounds it'll need to check.

Link to comment

Here's my best practices:

 

1. Try to avoid stacking, broadphase might go crazy;

2. Use real parameters like mass, velocities, forces, scale and so on;

3. It's better to use collision surfaces for static concave objects and collision shapes (BodyRigid with Shape or just BodyRagDoll) for moving objects like monsters/player/props;

4. Collision masks will help you to avoid heavy calculations in narrow phase.

Link to comment
×
×
  • Create New...