how do i code a bounce so that the higher you drop the object from the higher the first
bounce is then the bounce streghth reduces each bounce until it stops anyone know
to do this?
A crude way to do it, which could be improved with fastloops.
Set the Y movement corresponding to a counter...
Always:
- Set Y position to YPos (Object) + Value (Counter)
Every 0.05 sec:
- Add 1 to counter
When object collides with bg:
+ Counter > 0
+ Only one action when event loops
- Set counter to Value (Counter) + (Value (Counter) *-2)/3
Basically, this sets the upwards bounce velocity to 2/3 of the downwards bounce velocity, meaning the higher the drop, the bigger the bounce. The "Counter >0" part ensures the thing actually stops. This works most times, but sometimes gets stuck in a rut and falls through the object, which can be stopped by using fastloops, which I don't know really how to use. For different bounce heights, change the numbers used, like instead of *-2 and 3 use *-3 and 5, which makes the up bounce velocity three-fifths.
you don't want to use counters because having more than one ball object will cause problems. Using alterable values makes each ball have it's own independant bounce.