Search Unity

Resolved How to spot nearby triggers using a trigger?

Discussion in 'Physics' started by babaliaris, Jan 14, 2021.

  1. babaliaris

    babaliaris

    Joined:
    Apr 21, 2013
    Posts:
    40
    From the docs, I believe this is not possible using a trigger.

    My player needs somehow (every frame) to collect the first 10 nearest waypoints around him.

    These waypoints should be invisible and not block (collide) other moving objects. So they must either have a trigger collider or no collider at all.

    My first thought was to make a sphere trigger around the player and any waypoint that enters that trigger will be recorded. But this is not going to work since the waypoints are also triggers.

    My GameManager script has a list of all the waypoints, but looping them every frame for each player (4 players in total) in order to get the 10 nearest to the player can be very inefficient!

    So how can I solve this problem?
    Thanks!
     
  2. babaliaris

    babaliaris

    Joined:
    Apr 21, 2013
    Posts:
    40
    LOL, It seems triggers can detect collision with each other, false alarm.