Search Unity

Resolved getting function to run when entering an area ???

Discussion in 'Scripting' started by cowsharts, Dec 16, 2022.

  1. cowsharts

    cowsharts

    Joined:
    Dec 16, 2022
    Posts:
    8
    my goal is to have an enemy's chase function to start when the player enters the final area

    i attempted to have the function run if a certain block was se to false but this didn't work
    i also have a score counter that i use to open a door in another script and thought if i could reference it in the enemy script it would get the function to run

    code attached to enemy: Screenshot 2022-12-16 at 18.03.00.png
    code with score counter (not main score counter only used to open the door before enemy area)
    Screenshot 2022-12-16 at 18.03.21.png

    any help appreciated
    thanks :)
     

    Attached Files:

  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    If you want to check if the door is active, you should use

    Code (CSharp):
    1. if(!DoorToGo.activeSelf)
     
  3. cowsharts

    cowsharts

    Joined:
    Dec 16, 2022
    Posts:
    8
    working now! thanks so much :)