The Daily Click ::. Forums ::. Klik Coding Help ::. realistic bounce
 

Post Reply  Post Oekaki 
 

Posted By Message

TCC



Registered
  21/05/2006
Points
  40
5th June, 2006 at 18:10:11 -

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?


Image Edited by the Author.

 
hm?

Matt Boothman

The Nissan Micra of forum members

Registered
  20/09/2002
Points
  109

Game of the Week Winner
5th June, 2006 at 18:34:36 -

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.

 
http://soundcloud.com/normbo - Listen to my music.

TCC



Registered
  21/05/2006
Points
  40
5th June, 2006 at 18:41:36 -

ok thanks, will try it

 
hm?

TCC



Registered
  21/05/2006
Points
  40
5th June, 2006 at 18:59:08 -

it doesnt work :/ it passes through the background object with a slower speed

 
hm?

Matt Boothman

The Nissan Micra of forum members

Registered
  20/09/2002
Points
  109

Game of the Week Winner
5th June, 2006 at 20:24:14 -

Aah, yeah, the real counter value to set would be:

- Set counter to (Value (Counter) *-2)/3

Dunno why I added the other bit.

 
http://soundcloud.com/normbo - Listen to my music.

Deleted User
5th June, 2006 at 21:23:52 -

Make sure the counters minimum value is not 0...

 

TCC



Registered
  21/05/2006
Points
  40
5th June, 2006 at 22:32:23 -

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) *-2)/3

edit- lol it works if i use alternable value instead of counter x)


this time it makes a 1 pixel bounce and then keeps on falling :/


Image Edited by the Author.

 
hm?

Werbad



Registered
  18/09/2002
Points
  235
6th June, 2006 at 10:06:50 -

Always:
- Set Y position to YPos (Object) + Value (Counter)

Every 0.05 sec:
- Add 1 to counter

When object collides with bg:
+ Counter > 0

- Set Y position to YPos (Object) - Value (Counter)
- Set counter to (Value (Counter) *-2)/3

Try this...
The "Only one action when event loops" is not needed as far as i can see...


 
n/a

TCC



Registered
  21/05/2006
Points
  40
6th June, 2006 at 11:04:30 -

doesnt work either with counters but with alternable values it works good x) thx

Image Edited by the Author.

 
hm?

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
6th June, 2006 at 13:51:10 -

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.

 
.

Matt Boothman

The Nissan Micra of forum members

Registered
  20/09/2002
Points
  109

Game of the Week Winner
6th June, 2006 at 21:08:27 -

Oh yeah, the "collide with BG" should be "overlaps with BG", sorry.

Make sure you put the ball high enough so you can see it bounce.

 
http://soundcloud.com/normbo - Listen to my music.
   

Post Reply



 



Advertisement

Worth A Click