Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternatives for updating mesh collider in runtime?

I'm working on game where user generating mesh in runtime (all the time) so mesh have many vertices and in the same time there is a GameObject - player that need to trigger event when it is in area of this generated in runtime mesh.

Camera in this game is 3D, but this generated mesh is flat. In my attached drawing I show this in top view to better show how it looks like.

Now I'm updating Mesh Collider every few seconds, but it is very slow after generated mesh have more and more vertices.

I believe that this is very simple method of collision so maybe there is any other method to detect this instead of Mesh Collider attached to dynamically generated mesh?

UPDATE #1

I know that Mesh Collider is very slow and should not be updated in runtime. I also know the idea that should use primitives like box collider.

But in this situation when this flat mesh in updated every second (and it grow) it will be thousands of box colliders and new need to be added every second. This method will also not work.

UPDATE #2

My second idea is to find nearest triangles to player and create colliders for them (box colliders should be fastest). But I really have no idea where to start or it is even possible ? Someone ?

Drawing 2, as an answer for @Hristo

Drawing

like image 882
seek Avatar asked Apr 24 '17 21:04

seek


1 Answers

If mesh colliders work for small sections but not the full length, generate multiple mesh colliders, breaking off a new one every X number of polygons or X length of path as the player draws a longer path.

like image 122
Semimono Avatar answered Oct 15 '22 03:10

Semimono