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

How do I get a working ladder in my 2D Sidescroller?

Discussion in 'Scripting' started by KiritoKazuto99, Jul 25, 2014.

  1. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    I would use a boolean to trigger the animation. In the animator, click on the Run animation or whatever its called and change the condition from greater than float to boolean and set it to true. And the same from Run to idle except make it false.
     
  2. KiritoKazuto99

    KiritoKazuto99

    Joined:
    Jul 22, 2014
    Posts:
    36
    There is no script in the animator
     
  3. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Sorry not script animation
     
  4. KiritoKazuto99

    KiritoKazuto99

    Joined:
    Jul 22, 2014
    Posts:
    36
    So you want me to change the speed part to a bool?

     
  5. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
  6. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Change the name from "New Bool" to "IsMoving"
     
  7. KiritoKazuto99

    KiritoKazuto99

    Joined:
    Jul 22, 2014
    Posts:
    36
    Aww crap, the animation isn't working anymore. It's not because of the bool thing, I did some stuff in the wrong order and I need to redo the whole thing. Lemme get the backup from my friend and move the scripts and prefabs over
     
  8. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    lol Okay, this way I can optimize the ladder
     
  9. KiritoKazuto99

    KiritoKazuto99

    Joined:
    Jul 22, 2014
    Posts:
    36
    It says it's used by base layer.Movement still delete it?
     
  10. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Are you adding these to an existing project or are you following along with me with a new project? Sorry for the late reply I had to run some errands.
     
  11. KiritoKazuto99

    KiritoKazuto99

    Joined:
    Jul 22, 2014
    Posts:
    36
    I did it in a new scene but same project as the game
     
  12. KiritoKazuto99

    KiritoKazuto99

    Joined:
    Jul 22, 2014
    Posts:
    36
    Want me to start a new one and move the stuff over?
     
  13. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
  14. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Make sure you have reference to the avatar component in the Player script we made. And you assigned the animations to it.
     
  15. KiritoKazuto99

    KiritoKazuto99

    Joined:
    Jul 22, 2014
    Posts:
    36
    Do what?
    How do I reference it in the player script?
     
  16. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Make sure you have a variable of type Animator, reference in the new Player script we created. If you try to call animator.SomeMethod you will get an error.

    Code (CSharp):
    1. public Animator animator;
    Add this to the code for our player script at the top and drag the animator controller into that.
     
  17. KiritoKazuto99

    KiritoKazuto99

    Joined:
    Jul 22, 2014
    Posts:
    36
    what do I put in? I don't know what it would be.
    Sorry, since I am new to this I watch tutorials but they don't really explain what all of the stuff means.
     
  18. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
  19. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    No worries dude. Its the one that has some little boxes its called an Animator Controller.
     

    Attached Files:

  20. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    I called mine keyboard for testing purposes, yours might be called something else but the point is to have that dragged into the player script we made. You also have to make sure you have the Animator component attached to the game object you want to be animating. In this case the character with the cube body.

    Looks like this: Screen Shot Animator Component.png
     
  21. KiritoKazuto99

    KiritoKazuto99

    Joined:
    Jul 22, 2014
    Posts:
    36
    Drag it into the script?
     
  22. KiritoKazuto99

    KiritoKazuto99

    Joined:
    Jul 22, 2014
    Posts:
    36
    So you just want me to put the animator on my character?
     
  23. KiritoKazuto99

    KiritoKazuto99

    Joined:
    Jul 22, 2014
    Posts:
    36
    do you have a skype? it is faster to talk on there
     
  24. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Yeah PM me
     
  25. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Added you.
     
  26. KiritoKazuto99

    KiritoKazuto99

    Joined:
    Jul 22, 2014
    Posts:
    36
    I don't see anything