#Hey folks anyone here have use physics
1 messages ยท Page 1 of 1 (latest)
Hey, I think the formula to find the initial velocity (u) = sqrt-2as. You're missing the negative sign inside the sqrt.
Your code calculates : sqrt(2 * -980 * jumpHeight), which is the square root of a negative number.
So the correct calculation should be sqrt(-2 * -980 * jumpHeight).
so : Sqrt(-2.0f * Acceleration * Displacement)
๐ค
now thats doesnt work :(.. maybe im using mover instant movement effect wrong
i got my final velocity somewhere around 58,000
tested with set my jumpheigh whic i set to 300cm/s
then feed it here:
300cm/s * -980 * 2
which get absurd number
and mover velocity and its moveintent just register that as nand
i think this is a logic issue on my end
which i still cant figue out how to do this
close to just go to chatgpt for this
ugh
Are you getting 588000 ?
โ2รโ980ร300=588000
sqrt(โ2รโ980ร300)โ766.96
Yeah
Hmm i did similiar to this in A side
I'll double check tomorrow
Then you've forgotten the square root
okay so its somewhat a logic error on my end, kinda got it to work now
here my current solution
Yeah i think we solve the core math
Maybe you can simplify the CalculateJumpVelocity function to only calculate and return the pure jump impulse
Because it's just confusing and not reusable, like if another system in your game needed to know how strong a jump would be, you couldnt use this function because it does more than just calculate the value.
Why this is also responsible for handling the caracters existring momentum.
But that's if you want a clean code, you can do without it if it's a small project, i guess
yeah i could but maybe i'll hold off to that thought until i need it..not a lot of system need to get the pure jump impulse atm
@static tangle thank you so much for your help titoux.. learn a ton along the way ๐
Yeah np, just maybe one thing that i notice
In ActivateAbility, bAdditiveVelocity
So you manually created the final velocity but then told the effect to add it again by setting bAdditiveVelocity to true. This can leads to some bugs and incorrect physics.
So like let's say the character is on an elevator moving up at 100 cm/s. Their current velocity is (0, 0, 100).
CalculateJumpVelocity gets (0, 0, 100).
It zeroes the Z-axis, making it (0, 0, 0).
It adds the jump impulse, making the final velocity (0, 0, 423).
The character's jump is effectively weaker because the elevator's upward push was ignored.
So the Physics Realistic Code should be :
CalculateJumpVelocity returns only the pure impulse: (0, 0, 423).
ActivateAbility gives this impulse to the effect with bAdditiveVelocity = true.
The Mover component sees the character's current velocity is (0, 0, 100).
It adds the impulse: (0, 0, 100) + (0, 0, 423) = (0, 0, 523).
So it can really add a jump impulse