I was following this YouTube video and can’t seem to figure out the apex modifiers section?
How would I ensure that when a player is at the top of the jump they will get a moment of zero gravity for a speed boost?
I was following this YouTube video and can’t seem to figure out the apex modifiers section?
How would I ensure that when a player is at the top of the jump they will get a moment of zero gravity for a speed boost?
That’s not how jumping physics works. Look up basic kinematics. You are never in zero gravity. You may be at zero vertical speed, instantaneously. Even the International Space Station is not in zero gravity: it is constantly falling, but traveling fast enough laterally that it can never actually lose altitude and fall, but it is constantly being pulled at nearly 1g of acceleration, just like we are.
If you want to script a boost of some kind, that’s up to your design and specification.
design and mathematically define what conditions constitute the start of this “speed boost” you speak of
cause the speed boost to happen, perhaps either by a single instantaneous force or by a force applied over several frames.
I understand how to design and apply the force section. The issue I am having is calculating when the player GameObject is at the peak of its jump?
You might’ve been better referring to the video as nobody can know what you mean. It sounds like the video shows you how to do what you want but you just don’t understand it. Are you saying you want help understanding that or you’ve given up on that and want some alternate ideas on how to detect it at that point or are you trying to predicting it in the future?
You’re at the apex when the velocity has reduced to near zero in one axis or has passed through zero (inflection point). Or even simpler, when you’re jumping but the velocity has started moving you down.
Need more info really if you want specifics.
Apologies, I was meant to link the video it’s this one. [57s]
He even provides the source code, he just did it with custom physics not with the RigidBody etc, however he has since released an updated script however it’s behind a The updated does it with RigidBody and Colliders, so I know it’s possible. I also managed to make everything else in the video work pretty well, just this one left.
I think I figured it out, the way you worded when the velocity has reduced to near zero
made sense. this is the code I ended up with, let me know if you think it can be improved?
if (player.velocity.y <= 0.5 && isJumping)
{
player.velocity = new Vector2(player.velocity.x, player.velocity.y - apexBonus);
}
Excellent!
With enough gravity, or a low enough frame rate, velocity might larger than +0.5 one frame and less than -0.5 next frame, making your code not trigger.
I would personally compare the velocity this frame to the previous frame, and ask if previous was greater than zero, and current is less than or equal.
Are you just doing double jump? You’re welcome to see how I did it here:
https://www.youtube.com/watch?v=1Xs5ncBgf1M
Full source here:
proximity_buttons is presently hosted at these locations:
https://bitbucket.org/kurtdekker/proximity_buttons
https://github.com/kurtdekker/proximity_buttons
if (player.velocity.y <= 0.5 &&player.velocity.y >= -0.5 && isJumping)
{
player.velocity = new Vector2(player.velocity.x, player.velocity.y - apexBonus);
}
do it like this otherwise it will trigger while you are falling