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

Door swing with a trigger question

Discussion in 'Getting Started' started by musicartslao, Jun 10, 2017.

  1. musicartslao

    musicartslao

    Joined:
    Nov 9, 2013
    Posts:
    13
    Hi,
    I have a "WoodenGate" in a hierarchy like this:
    1. WoodenGate (Mesh with a mesh collider)
    2. doorOpenColliderTrigger (GameObject/3D Object/ Cube with the Activatetrigger script Component)
    3. door (Mesh with a box collider)
    I also have the standard FPSController in the scene.

    My problem is that the opening door animation keeps playing in loop, before my player hits the trigger(doorOpenColliderTrigger).
    I am missing something very simple here...

    Thanks for any help!

    LAOMUISC ARTS
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Not really a lot of information to work with..
    Are you using the animator or animation? If it's the animator, do you have transitions setup correctly?
    If it's animation, did you tell it to play in a script or the inspector?

    Is there any code related to this that may be causing the problem?
     
  3. musicartslao

    musicartslao

    Joined:
    Nov 9, 2013
    Posts:
    13
    I am using keyframe animation (Window/Animation).
    The only script in play is Unit´s Activatetrigger [doorOpenColliderTrigger (GameObject/3D Object/ Cube with the Activatetrigger script Component)].
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    But you're saying that the animation just plays all the time?
     
  5. musicartslao

    musicartslao

    Joined:
    Nov 9, 2013
    Posts:
    13
    "My problem is that the opening door animation keeps playing in loop, before my player hits the trigger(doorOpenColliderTrigger)."
     
  6. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Sorry, either the door is colliding with the wrong object to cause the animation, maybe.. or the animation is set to loop is all I can think of.
     
  7. musicartslao

    musicartslao

    Joined:
    Nov 9, 2013
    Posts:
    13
    That´s the point: where do I turn the loop off?
     
  8. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Okay, so I'm just guessing your setup is like this.. if not, you could alter it, I guess.
    I think maybe I found what's happening to you.
    If I add a simple animation (just moves right + 3 units , for a cube) and I put it in the animator, it's the default animation.
    That means, it just plays on entry.. I cannot even move the cube anywhere, b/c it's always setting it to that value.
    So, I made a second animation or whatever.. just set it to position 0 (start).
    Then, I added a transition based on bool or trigger.. either would work. And that condition had to be met for the cube to move. This way, it's not always playing. It just does the transition on bool change or trigger activation.
    note: with a bool, i could turn it false & return its position back to the original, which may be useful for a door.

    Anyways, hope that helps.. sorry for the bit of confusion - I hope this post makes sense & you can implement it.