+ 2
how to create a bounce effect
I don't know how make this effect, i promise you can help me
1 Respuesta
0
you can do this by changing the sign of the "down"-movement and multiply it with a value smaller than 1 (=> object slows down every bounce) when hitting the ground. now your object moves up, and your gravity function draws it back to the ground, where it bounces and looses speed again.
you can stop bouncing by checking the reflected speed for a minimal value. so the object bounces less with each hit and stop after a while.
if the multiplier, lets call it friction, is 1, the object will bounce forever. if its bigger than 1it will gain speed every time it hits the ground and bounces higher with every reflection.
if you doesnt like that "higher friction value" causes more bounce-speed, you can use it as a divisor. so friction=2 will half the speed every bounce, friction=4 quarter and so on...
if you want to add side movement you will have to multiply/divide the side-speed with friction too, otherwise your bouncing looks very strange