Day 108: Ladder System Part 2

Objective: Climb up the ladder and automatically get off at the top.

Today we will discuss how the ladder will automatically start the animation to get the player off the ladder and onto the next platform.

Yesterday we set up the Ladder script. Now we will need another script to exit the ladder. In this script we will use OnTriggerEnter to start the movement from the ladder.

Under the Ladder game object we will have a cube object with the mesh renderer disabled, also with Box Collider set as IsTrigger. This is where the script will be.

Before we add anything else to this, we will need something to call to start the process of getting off. Back in the Player script we will create a method called PlayerGetOffLadder. In here we will disable the character controller and call an animation bool. More on the animation tomorrow.

Now our animation will run and we will need set the position of the player at the top when the animation ends. To do this we will create a Behaviour script on ClimbingToTop animation.

In this Behaviour script we will un comment OnStateExit and call the player script. In this we will call a method from the player script.

In the player script we will create another Method called PlayerOffLadder. In this method we will set the players position to EndPos of the ladder. Next is to set the climb ladder to false, re-enable the character controller and set the climbing ladder animation bools to false.

Now to get the position from the active ladder. In the ladder script we will create a return type method that returns a vector3. We will return the EndPos that we have assigned.

Now in the scene view, we can see where the EndPos is located at. This will need adjustment based of the ending position of the animation. The animation that was picked for you could have a different end position for me.

That is the end of the Ladder behaviour.

Thank you for reading and have a wonderful day!

--

--

--

I am passonate on learning to program and use Unity to become a skillful Unity Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

3 Tips For Maintaining Your Scala Projects

The Magic Of AWS CLI v2

Implement ActionListener In Flutter

Pre-requisites to Practicing Reliability?

“Ruby on Rails”, is probably the thing that I’ve heard the most in my journey to learn to program.

Rejection In The Akka HTTP: Let’s handle errors scenarios more properly

Product Hunt launching and how it helps with Covid-19

My First Job as a Dev on the Pathway

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tyler Smallwood

Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer

More from Medium

Day 107: Ladder System Part 1

Procedural Generation with Prefabs: Part 2

Mastering Unity Scripting | Summary — Chapter 3: Singletons, Statics, GameObjects, and the World

Dust to Dust — Creating and Destroying Objects in Unity