View Full Version : how do i make a ball roll off a table and bounce on the ground
bromsburg
02-02-2009, 03:02 PM
while the ball is bouncing, i want to make it come to decrease the height of the bounce before coming to a rest
ottar9919
02-02-2009, 06:15 PM
There are two ways you could do this.
One way is to have the ball move up, say 5 meters, and back down 5 meters. Then make it move up and down 4 meters, and 3 meters, and so on.
The other way is to make a number variable(lets call it X). In a loop, put "ball move up X meters" and "ball move down X meters". After that, put in "variable X decrement by 1". Loop it X amount of times.
Here is an example of both ways:
bsmill04
02-08-2009, 02:05 PM
I would suggest the variable way. Decreasing by 1 instead of adding 5 different up 4 down 4 up 3 down 3.
haven812
12-10-2010, 11:27 PM
Another way to achieve the bouncing effect is to insert a recursive method. Create a method named bounce in the object you want to bounce with the following number parameters- startHeight, and numberOfBounces. In the method insert the following, replacing ball with the object you want to bounce-
if numberOfBounces > 0
ball move up startHeight meters, style end gently, duration = startHeight/4
ball move down startHeight meters, style begin gently, duration = startHeight/4
ball.bounce(startHeight=startHeight*0.75, numberOfBounces=numberOfBounces-1)
Else
Do Nothing
Now you can call the bounce method any time, inserting the number of meters the ball starts to bounce at, and the number of bounces that the ball should bounce. I also attached an example of this using a basketball.