portwash.blogg.se

Jummp time
Jummp time




jummp time

You want to make sure the jump takes a second? What gravity should it have? I'm also going to remind that you probably want coyote time and jump buffering (look it up). However, not setting the velocity to zero will be a problem when it walks to off a ledge, since it would have stored speed. we don't set the velocity back to zero when the character is on floor. we are checking is_on_floor after move_and_slide and 2. Although I don't expect it to be a problem with this code, since: 1. That is because there is a Bullet integration bug that gives inconsistent results for is_on_floor. Here I'm using is_on_floor, so make sure to put a solid floor for your character to stand in.īy the way, I'm going to recommend to set the physics engine to Godot Physics on Project Settings -> Physics -> 3D. What? It went through the floor? Well… export var velocity := Vector3(0, -25.0, 0) We can store it in a varia… Look, let us compute the change in velocity delta_velocity after a time delta (you do have delta): velocity_a = a*t + bĪdd gravitacional acceleration, and we do this: export var velocity := Vector3(0, -25.0, 0) What do you mean what time? It is the time at which the jump began. So that is our vertical velocity (change in height respect the change in time): velocity = a*t + b Ask Wolfram|Alpha to do it: differentiate with respect to t Differential calculus… No, no, come back. And we must use that so it interacts with the game physics. Oh, but Godot wants a velocity for move_and_slide. You set a vertical speed, wait half a second and then set another vertical speed.ĭo you remember vertical throw? We want a motion that follows this formula (with time as parameter t): y = c + b*t + (1/2)a*t^2 Wait, you start the timer again, but you don't wait on it? Oh, it is just this: velocity.y = SPEEDĪnd hopefully that is simple enough that you can read what is going on. Is functionally equivalent to this: velocity.y = SPEED Here we are using a SceneTreeTimer, which will be freed after it is done. We can do something different, which will not have that problem, it is just one line, and it is functionally equivalent: yield(get_tree().create_timer(0.5), "timeout") Notice that you are adding timers as children every jump (and I don't see you remove them): var t = Timer.new() Is equivalent to this: velocity.y = SPEED You are doing this: velocity.y = lerp(velocity.y,0.0,1.0) If you were to pass a weight between 0.0 and 1.0 you would get a result in the between the initial and final value - and the point of lerp is that you would keep the initial and final values and steadily change the weight. And if you pass a weight of 1.0 you get the final value to. If you set pass a weight of 0.0 you get the initial value from. If I were to implement lerp in GDScript, it would look like this: func lerp(from:float, to:float, weight:float) -> float:






Jummp time