Search Unity

Danger Detector( The best solution)

Discussion in 'Physics' started by darthachill, Mar 10, 2015.

  1. darthachill

    darthachill

    Joined:
    Jan 25, 2015
    Posts:
    27
    I try create AI Enemy but I'm stuck.
    I'm thinking about something like Danger Detector. Enemy see That some object approatching to him, and he try to avoid Collision. What is the best way to create something like that? I came up with 3 Ideas.

    variables:
    float sightDistance // max detector distance

    1) Add Collider To my enemy, but there is annoying problem with setting size collider(sightDistance) in script,

    2) Add Camera, set Projection->Orthographic, adjust size to Enemy. In script I can change my sightDistance in simple way.

    3) Use RayCast, but if the object, that is approaching to Enemy, is too small , RayCast doesn't detect it.

    Thx for your help