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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Animation Transitions Not Working? (2D)

Discussion in 'Animation' started by WordPadGamer, Jul 7, 2015.

  1. WordPadGamer

    WordPadGamer

    Joined:
    Jul 7, 2015
    Posts:
    5
    When the game is started the sprite is continuosly going through the walking animation even when it has stopped moving. My aim is to stop the animation when the character stops.

    Any help would be greatly appreciated.
     
  2. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,511
    So, the sprite continues animating while the blue bar in the state has stopped, or the sprite stops animating while the blue bar in the state continues?

    Either way, I find it odd. Does the anim clip have the loop flag set? Are there any scripts attached that may influence the behavior?
     
  3. WordPadGamer

    WordPadGamer

    Joined:
    Jul 7, 2015
    Posts:
    5

    The blue bar works as normal and the loop flag is not set and their is no scripts affecting it. I was trying to find the way of changing the animation of the character when he stops.
     
  4. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,511
    How many states do you have in the controller? Do you have an idle state that can serve as your "stop" state? Your original post says you want a way to stop the animation. But your last post says you want to change the animation. Not sure what you mean by this. So, the blue bar working as "normal" without the loop flag, that means the bar stays full with blue, and the animation has also stopped, right? Or is it continuously going like you said in the original post?
     
  5. WordPadGamer

    WordPadGamer

    Joined:
    Jul 7, 2015
    Posts:
    5
    i got confused in the first post sorry. The animation is continuous but i want to be able to change the animation to an idle animation( that is what i meant by stopping the animation). I have 2 states in the controller and i do have a "stop" state but i d not know how to change it to the stop state.

    Sorry for the confusion i am a noob at unity first game!:)
     
  6. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,511
    In the Animator editor, there's a params tab on the left. Add a new trigger, name it something like "stop". Then, click on the transition arrow between the walk and stop states. There's a condition section. Select the drop down to " stop". Then in your script, you can call GetComponent<Animator>.SetTrigger("stop")
     
    theANMATOR2b likes this.
  7. WordPadGamer

    WordPadGamer

    Joined:
    Jul 7, 2015
    Posts:
    5
    That's exactly what I was looking for! But the set trigger part shows up red?
     
  8. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,511
    "Shows up red"? Like, syntax check? What version of Unity? Not sure if it matters. i.e. whether it's available prior to 5.0.
     
  9. WordPadGamer

    WordPadGamer

    Joined:
    Jul 7, 2015
    Posts:
    5
    sorry for the late reply i had to go on holiday but i will uploada screenshot of the problem to give some clarity of what i mean.
     

    Attached Files: