Search Unity

Just playing an animation by click on an object?

Discussion in 'Animation' started by Asta_D, Mar 19, 2015.

  1. Asta_D

    Asta_D

    Joined:
    Oct 16, 2013
    Posts:
    15
    Hello

    I am a beginner in Unity but i get slowly used to it. I come from the 3D-Animation, using Unity itself (the Interface and all that) is not the problem. I even got it to set up a scene with my objects an naviagte in it. so you can seleckt an Object (by Buttons done with the new Gui-System) and then you can mouseorbit around the selected object if you held the mousebutton down. Works fine so far.
    But now i want to play an animation. One object is a box that can be opend. I did the open and close animation an tryed out the Animator controller. I understand the stuff with the transitions, but how do i tell the animation that it should only play if i click on the box? I tried raycasting and i got it to work, that clicks on the Box were detected , but how do i connect this to the open-animation? I tried it wit the Animator scripting tutorial, but my animation is playing all the time ... open-close-open-clsoe ... all the time.
    So how do i start the animation just by clicking on the box?
    Like:
    Box is close -> click on it -> box opens
    Box is open -> click on it -> box closes

    I only find older tutorials for that simple task, but how they do it dosen't work in Unity 5.

    Regards from Germany
    Asta
     
    Last edited: Mar 19, 2015