Search Unity

Question detecting the edge of a collider

Discussion in 'Scripting' started by puddleglum, Apr 23, 2022.

  1. puddleglum

    puddleglum

    Joined:
    May 11, 2020
    Posts:
    412
    i have an "ai" if you can call it intelligent. that basicly follows the player where ever he goes. im gonna eventually make this into a boss. but i need the boss to detect the edge of colliders aka the floor. the floor is suspended above spikes and he cant fall in. i literally have no idea how to start coding this in.
    i had an idea of making a circle collider at its feet and add an ontriggerexit so when it leaves the floor collider it sends back a message to stop the ai. but this seems pretty janky so im trying to find something else.
     
  2. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,648
    You could try to use a NavMesh to find areas which are walkable, which will also help with pathfinding supposing your character is behind a pillar or something.
     
  3. puddleglum

    puddleglum

    Joined:
    May 11, 2020
    Posts:
    412
    ok ill check it out