Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

JavaScript > Collider / Trigger Help

Discussion in 'Scripting' started by Khazzack, Dec 10, 2013.

  1. Khazzack

    Khazzack

    Joined:
    Sep 27, 2013
    Posts:
    29
    Hey guys.

    I'm new-ish to triggers / colliders. I have this script.

    Basically, when the player enters the collider / trigger area, and i press "e" the "open" if statement is true so the animations of my "gate" should play and the player can then walk into the "open gate".

    I have the animations set up and have referenced them correctly to play.

    In my hierachy, i have my "Gate" as an empty game object with The Sphere Collider as "Trigger", my Gate script is also attached. Connected to the empty game object "Gate" i have GateLeft and GateRight. These both have the correct animations for them, an open and close animation.

    play automatically is toggled off and the "wrap mode" is set to once.

    but then when i press "play" in Unity, to "Gate" is already open and cant be shut and the GUI doesnt come up. What am i doing wrong?

    thanks