0
\$\begingroup\$

I tried to calculate the bounce height for the bouncing ball however it ends up shaking against the moving platform after it finishes bouncing. grav_val in this case is 0.1872 to prevent it to shake from normal surfaces after it finishes bouncing as a temporary fix.

yspeed = -max(0,(rounding(abs((yspeed + platform) / 2) - (grav_val) , 0.1)) + platform);

What the rounding function does is just rounds by a factor of whatever the second argument's number is.

return (input / factor) * factor

Finally, platform is the vertical speed of the platform that moves up, so let's hypothetically say it's in the speed of two for example:

platform = 2;

So, basically I want it to fully diminish until it hits to zero regardless of yspeed adding itself because it does right now due to gravity and the platforms. Rewrites or new methods would be appreciated.

\$\endgroup\$
2
  • \$\begingroup\$ I don't know if this is considered a bump but i still am stuck at this however i got into a new method done: yspeed = -((abs(yspeed) / 2)); if (abs(yspeed) < 0.5) yspeed = 0; but how could i take moving platforms into account when it comes to bouncing, that's all I'm asking. \$\endgroup\$ – mack Apr 14 at 3:27
  • \$\begingroup\$ Welcome to GDSE. In this case, I would recommend editing your question to include the revised formula & the information about how it's not properly accounting for moving platforms (i.e. what happens versus what you want). \$\endgroup\$ – Pikalek Apr 17 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.