Search Unity

meshCollider.sharedMesh.vertices positions without reassigning sharedMesh

Discussion in 'Scripting' started by Toylips, Mar 17, 2019.

?

Would you like to correct sharedMesh.vertices positions without re-enabling sharedMesh

Poll closed Sep 17, 2019.
  1. Yes

    1 vote(s)
    100.0%
  2. No

    0 vote(s)
    0.0%
  1. Toylips

    Toylips

    Joined:
    Feb 15, 2013
    Posts:
    28
    Hi everyone!
    I did some code for selection units via triggered zone in RTS that have a pyramid form and for creating selection zone I need to recalculate vertices positions every frame when I'm creating rectangle for selection, but for applying vertices positions on collider I need to do this - meshCollider.sharedMesh = mesh. and this thing restart trigger,
    OnTriggerEnter and OnTriggerExit spam every frame.

    Why we can't use meshCollider.sharedMesh.vertices =vertices; like in PolygonCollider2d?

    I know how to create selection with list of object and their positions - it will not help because I have a preselected state and it will spam garbage too. and I need just touch a bit the unit to select like collider do it