- Home /
How to read jump height of character?
This is going to be for a BMX, MTB, Skateboard etc., high jump competition. The charactor will go down initial ramp to gain speed, and hit a vertical jump, going straight up into the air and back down the ramp. How would I find the max height of each character, and how would i display it on a leaderboard directly behind and above the jump?
add a score script to each player which have a maxheight variable. assign maxheight = firstCharactersJump first. the check in Update function whether the characters > maxheight then update the max height to maxheight = charactersCurrentJumpHeight.
Answer by PVusanGamse · Apr 04, 2020 at 11:59 AM
You just need to STORE your MAX value of some character GAME OBJECT transform.position.Y in some static value. In Update() method try to do: print(gameObject.transform.position.y) and you will see in console what I mean.
As a recommendation, if you are beggining code, do not use static variables.
Answer by tormentoarmagedoom · Apr 04, 2020 at 11:55 AM
Hello.
First, you are asking more than 1 thing in one post. You need to advance step by step.
To calculate the height, just need to check the vertical component of the object each frame. Store the value on a variable called something like "maxheight". Each frame compare the current height with maxheight and if is higger, replace it. So at the end maxheight will be the highest height reached.
After, you need to create a Canvas text and show the maxheight value.
Repeat this for each player!
PS: You are beggining, dont try to go fast, go step by step, learning each thing and understanding what and why are you doing that.
Good luck!
Your answer
Follow this Question
Related Questions
How can I find the distance from one object to another using raycasts? 1 Answer
Jarring "snap" on 2d Camera raycast collider 0 Answers
Is it possible to measure distance's between raycast intersections? 2 Answers
how do I restrict my shooting script's raycast to a certain range? 2 Answers
End game with certain amount of points with distance 1 Answer