PlayMaker Help & Tips > PlayMaker Help
Can't get consistent jump height at different framerates
Mupp:
I'm trying to make a 2d platformer using 3d physics and I can't get jumping to work consistently. As the framerate fluctuate, so does the jump height and I need close to pixel perfect jumps.
The jump should have its height dependent on how long you hold the button. To do this I've tried timing how long you can be in the state with a wait action(real time checked or unchecked), create state loops with next frame event action and neither works for timing.
I also tried launching the player using add force, set velocity or translate. Every combination creates the same problem. I've even tried creating my own gravity and disabled the built in one.
Nothing works so I must have fallen in some trap I don't know about.
So now I could really need some help please on how to create a state that does a jump with a height dependent on how long you hold and jumps exactly the same height regardless if the framerate is 10 or 200.
djaydino:
Hi.
I am not sure how you calculate the jump, but maybe the action "Get Time Info" can help.
You can get the time in current state
so when button pressed, go to next state (with that action in it) and on button release go to next state then you will have the time the button was pressed and you can then calculate the jump height
jeanfabre:
Hi,
you need to use animation based on time.deltaTime ( action GetTimeInfo), then you get a fps independent animation when you move things around.
Bye,
Jean
MarkD:
I'm having a similar problem and I'm unsure how to use the time.delta time action to fix the issue.
In my project, I want jump height to be the same every time the jump button is pressed. And, similar to creator of this thread I'm getting different max height values on each jump due to frame rate.
Here's what I'm doing:
State 1:
Curve Float from jumpSpeed (25) to Zero over jumpTime (.15)
Set Velocity to jumpSpeed every frame
We exit that state once the curve float action is complete.
State 2:
Get Y position of the player for debugging purposes
Wait here for "hang time" (.15)
State 3:
Same as State 1 only curving the float from 0 to jumpSpeed until ground is hit.
Using this, I get a different Y value every time. Can anyone suggest a way to get a consistent height each time? I tried using GetTimeInfo/Time.deltaTime but I wasn't clear exactly how that was supposed to help me here. Maybe I'm just missing something.
Can anyone point me in the right direction?
jeanfabre:
Hi,
you need to sample your curve with the delta time as multiplier.
say you want to animate over 1 second and your curve span over 1 as well.
keep a variable "time",
- set it to 0 at the jump start
- on every update, add delta time to the "time"
- sample the curve at the "time"
this will guarantee a consistent behaviour regardless of the fps.
Bye,
Jean
Navigation
[0] Message Index
[#] Next page
Go to full version