Search Unity

Set the current animation's time to the last frame

Discussion in 'Animation' started by Vojta Koci, Jan 24, 2015.

  1. Vojta Koci

    Vojta Koci

    Joined:
    Nov 19, 2013
    Posts:
    64
    Hi everyone! I have little problem and I need your help desperatly.
    I am creating a animation system for my character. It has several animations in it, but only one is problematic. The animation clip is called "Run". The problem is, when the character runs left, the speed of animation is set to a negative number. When I run left right after start, nothing is played. But when I first run right and then back left, the animation is played correctly until the player reaches its starting position. I assume the animation.time can't be <0. I want to achieve something like this:

    if (the animator's currently played animation (looped) is called run and its time is == 0){
    set the animation time to the last frame and continue playing the animation smoothly}

    Is anything like that possible? I'm sorry for being so lame, but I'm new in animation systems and I culd not find the answer. I'd be very glad for any tips.
    Thank you guys and haev a nice day!
     
  2. Jself

    Jself

    Joined:
    May 29, 2014
    Posts:
    56
    Screenshots of your animator table with the statemachine connections and inspector of the state settings could help describe your problem.
     
  3. Vojta Koci

    Vojta Koci

    Joined:
    Nov 19, 2013
    Posts:
    64
    Picture attached. All transitions are muted, my problem is just about the running animation. When I set the animation speed to -1, the character does not move at all. But when I set the speed to 1, let him run for a while and then I set the speed to -1 again, it runs backwards for a while, until it reaches the starting point. Then is stops again.

    I'd be really glad for any help...
     

    Attached Files:

    • anim.jpg
      anim.jpg
      File size:
      240.2 KB
      Views:
      892
  4. Jself

    Jself

    Joined:
    May 29, 2014
    Posts:
    56
    Hmmm. You do have some "speed" conditions setup for the transitioning between states.

    So if you do. You need a speed condition to and from the idle state. For idle to moving forward. You would need a "greater" than 0.1 condition to get out of idle and into moving forward. This running state would have your locomotion blends.

    Running backwards would be in a separate state with different speed conditions. 0 should be idle state. Speed above 0.1 should be moving forward state. Greater than -0.1 speed should be moving backwards. Less than -0.1 should be back to idle state conditions.

    This video goes over these basics. I can't say if it is a standard to adopt, but I don't see why not.



    There could be some script conflict as well.
     
    theANMATOR2b likes this.
  5. Vojta Koci

    Vojta Koci

    Joined:
    Nov 19, 2013
    Posts:
    64
    Well, I think I understand everything in the video, my problem is kinda more complicated. There's no idle state. Instead, the speed of running animation is 0. I think I'll create two separate animations for running left and right. I was just curious about possible different solution.
    Thank you!
     
  6. Jself

    Jself

    Joined:
    May 29, 2014
    Posts:
    56
    If you are using Humanoid animation type, you can create one turning animation and just mirror it for the Right variation. If you are using Generic, then yea. You will need to create the Right turn animation. (Just trying to help you save time)

    But it is pretty much standard practice to have a Idle state. So I would get into the practice of having one for your characters.
     
  7. Vojta Koci

    Vojta Koci

    Joined:
    Nov 19, 2013
    Posts:
    64
    Yes, I know. But for my character, there should be no idle state. It's basically a hand running on its fingers, so it does not tur around, but runs backward and when it stops, it is just "stuck". I can't describe it, but problem solved, thank you very much!