- Home /
How to check if the player is at the top of the ladder?
Hello, I am making a 2.5D game and I need to check if the player is on top of the ladder. Here is how my code works:
ladders are trigger colliders
if the player touches the ladder,
then allow vertical movement (climbing the ladder)
I want the player to be able to stand on top of the ladder and be able to jump off it. So how do I check if the player is at the top or not?
What I would do is - If it is a Rigidbody character you are making, just make the character Is $$anonymous$$inematic so no physics apply to it.
Otherwise, I would think that doing a Physics.gravity I believe the code is called and make the y axis 0. That should (in theory) make him not fall, then do an OnTriggerExit and return the Gravity again.
Hope that helps!
Answer by Kiwasi · Sep 26, 2014 at 02:39 AM
Put another trigger at the top of the ladder.
There are several mathematical solutions available. The simplest would be to compare the y values of the top of the ladder and the player. This is not as simple as the trigger method. I suggest leaving it until you need the optimisation.
Your answer
Follow this Question
Related Questions
Create scripts to climb a ladder 0 Answers
How to climb up a ladder!! 1 Answer
3rd Person Ladder/Wall Climb Script 1 Answer
Can't click gameobject when over another trigger? 1 Answer
Climbing a Ladder in 2D Physics World 0 Answers