Perfect Jump Using Math - Godot Third Person Controller #2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys this is Johnny and if you're making jump Mechanics for your game and you're using jump velocity and gravity to fine-tune the mechanics it might become a tedious process of trial and error in this video I'm going to show you how you can Define the exact height of the jump and the duration of reaching the top using some simple math formula this not only makes the work straightforward but also makes the level design and game design easier to get the jump velocity I'm going to consider this a linear motion as I'm only going to need the vertical velocity for linear motion we know that the average velocity equal distance ID time we can write it as U of the initial velocity plus v the final velocity / 2 equal D / by T for the jump motion the distance means the height of the jump and V or the final velocity becomes zero as the player comes to a complete stop when reaching the top so V gets out of the equation and from this we get a simple formula where the initial velocity is equal to 2 * height / by time in the movement controller script I'm going to modify the velocity y of the jump velocity using the math formula which is 2 * jump height divid by Apex Direction which means the time to reach the height if you're wondering about this jump State I'll explain this later in this video to get the value of G I'm going to use this equation which is acceleration equals a change in velocity divide by time or we can write this as a = vus u / T and for jump motion we can put G in place of a which is negative because the force is downwards and as V equals 0 at the top it gets removed from the equation so now we get gravity equals initial velocity divid by time again in the script I've introduced a jump gravity variable which I'll modify like this using the formula here's how the jump looks like each line here represents one unit of distance and you can see the player's jump height and duration matches the amount I'm putting here if you watched my previous video I've already CED the basic movement mechanics and for the jump mechanics I've created another simple State machine like before so that I can have multiple types of jump jumps with unique jump Heights and durations in this case a ground jump and an air jump I'm sending the jump stage from the player script where I've also implemented the double jump mechanics which I'm going to explain in the next video you can download the entire project for free from H and I'll leave the link in the description I will introduce another variable fall gravity so the player can fall at a different speed so here in the physics process I'm only applying the jump gravity when the player is jumping otherwise the fall gravity is applied so that I can ensure the player Falls faster to create a smooth experience I'll use these values for the ground jump and these for the air jump in the next video I'm going to explain the double jump mechanics and also how I blended the animations in the animation [Music] [Music] tree
Info
Channel: Johnny Rouddro
Views: 4,302
Rating: undefined out of 5
Keywords:
Id: t_E8EyXp37g
Channel Id: undefined
Length: 2min 51sec (171 seconds)
Published: Thu Feb 08 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.