Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Run away a.i.?

Discussion in 'Scripting' started by Dpikachu1, Nov 8, 2014.

  1. Dpikachu1

    Dpikachu1

    Joined:
    Nov 8, 2014
    Posts:
    2
    Okay, so I am making somewhat of a horror game where you only have a flashlight and you are being chased but you can make that person (who is chasing you) go away by shining the flashlight on them, but I can't seem to figure out how to do it?

    If anyone know's please help!

    Thanks!
     
  2. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    Sounds like a use-case for navmesh. When you shine a light on the monster, give it a destination somewhere far away from the player.
     
  3. Dpikachu1

    Dpikachu1

    Joined:
    Nov 8, 2014
    Posts:
    2
    Any idea on how I would code that? (Sorry first time trying a run away ai)
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,523
    A simple "flee" steering behavior might be easier. Here's a tutorial on steering behaviors, and here's the specific section on the flee behavior. The code is in ActionScript, but it's very similar to UnityScript.
     
    Epictickle likes this.