Newbie question regarding mesh colliders & physics

0
miya posted this 22 October 2016

Hello,

As someone that thinks PicaVoxel looks quite neat, I do have a (possibly stupid) newbie question. I checked both the manual and forum before asking, so I hope I didn't miss the answer already answered - I can say I tried looking!

So, say I want to make a voxely game. I also want to use Unity's physics. Using Unity's physics is all good, but the problem of course comes when we get to how PicaVoxel does collisions, from what I understand.

My questions therefore are: -For voxely "terrain", I would either need box colliders (if simple) or the mesh collider (for any chunk that isn't simple). How many "chunks" would I be able to give mesh colliders reasonably without making performance blow up? 20? 30? Is that already too much? Is more okay? What's the rule of thumb? If it helps, for "area" voxels of this nature, I am likely going to have each voxel represent a size of 1x1x1 Unity unit, ie one "meter", the distance my character is able to jump. Details like grass, trees, statues and the like would be done with smaller volumes without mesh colliders. -Assuming that I get to a point where I have to add mesh colliders often (for the individual scenes and rooms) and that I can do so without making performance go haywire, is it possible for me to modify the "generate mesh only copy" function to automatically add a mesh collider to every chunk?

Thank you for answering, in case you decide to do so! :)

2 Comments
Order By: Standard | Newest | Votes
0
GarethIW posted this 22 October 2016

PicaVoxel generates mesh colliders for you. You can choose whether you want concave, convex or no meshcollider. Each chunk of a volume is assigned its own mesh collider.

For a voxel "terrain", you would want to use a concave meshcollider. Now I know there are limitations with concave meshcolliders in PhysX, so you might want to look into the Unity manual to check that the other colliders in your game will interact correctly.

Performance will always depend on the size and complexity of your terrain. It will depend on how you are doing terrain i.e.: are you using one large PicaVoxel volume or are you planning on doing some kind of streaming solution where you show and hide parts of the terrain. Performance will also depend on the chunk size you use. Smaller chunks will be faster at runtime when voxels are added or taken away and the mesh is regenerated, but smaller chunks also means more meshcolliders.

So I'm afraid I can't really give you an estimate on physics engine performance as there are far too many factors at play, and much of it has to do with Unity and PhysX more than PicaVoxel specifics.

0
miya posted this 23 October 2016

Thank you all the same, because now I at least know where to look to check/test this stuff :)

When I tried it, Pica didn't actually create a mesh collider, that's why I was asking. It did make the mesh, but no collider (adding it worked fine, though).


Our 330 members have posted 404 times in 96 discussions