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

mid jump to climb animation

Discussion in '2D' started by harveyshideout, Feb 15, 2016.

  1. harveyshideout

    harveyshideout

    Joined:
    Jan 12, 2014
    Posts:
    33
    hello i have a 2d platform character that moves left and right and a jump blend tree, a climb up animation that is activated by a trigger on the edge of a platform. When he jumps, I turn off the gravity and velocity, the trigger is activated in the parameters but the character does not transition just remains mid float, I have the climb node attached to the jump blend tree, I have tried linking through anystate too but it still does not transition, can anyone help with this?

    http://paste.ofcode.org/39FukpxWB4UtF6BnZr8HCpi
     
  2. harveyshideout

    harveyshideout

    Joined:
    Jan 12, 2014
    Posts:
    33


    a quick video
     
  3. Q-ro

    Q-ro

    Joined:
    Feb 14, 2016
    Posts:
    10
    Well, I'm not entirely sure why the animation is not playing, i can see that the animator trigger is being set, perhaps you should check the animator transitions and see if you didn't make a mistake as to when to transition from jumping to climbing ? I mean, the code you have will always achieve the result you are seeing, you are disabling gravity on the character so he will never fall (a.k.a. he will be stuck in mid air), and you are killing it's momentum, you are however not disabling the player's ability to move, so he can press a direction and he will be able to move "normally" while locked in the Y axis ('cause of no gravity).
     
  4. geek_freek

    geek_freek

    Joined:
    Aug 26, 2014
    Posts:
    51
    Well, this might be a bug but seriously it looks cool. You could try using this as one of the powers.

    As for the bug ,
    ->From seeing the video , gravity has to be reset to its original value as to when the player was on ground.
    So that he falls down.Try doing it when Player exits Collider.

    ->What is the exit transition on climbing state ?

    ->Maybe it is setting the trigger 'climbUp' but is also exiting the climbing state back to jump state.

    ->If that is not working try using bool checks on climbing as well.
     
  5. Q-ro

    Q-ro

    Joined:
    Feb 14, 2016
    Posts:
    10
    I have to add that the code you provided has something extremely weird, by that a mean abunch of brackets opening and closing on all over the place:

    void OnCollisionEnter2D (Collision2D other){

    if (other.gameObject.name == ("platformEdge")){
    {
    GetComponent<Rigidbody2D>().velocity = new Vector3(0,0,0);
    GetComponent<Rigidbody2D>().gravityScale = 0;
    myAnim.SetTrigger("climbUp");
    climbPos = GetComponent<Transform>().position;
    }
    }

    {
    Instantiate (dustCloud, new Vector3 (xLoc-.2f, yLoc - .1f, 0), dustCloud.rotation);
    }
    }

    I don't even understand how that script is compiling.