Skip to main content
Participant
April 3, 2014
Question

Need Help giving a ball gravity & friction (AS3)

  • April 3, 2014
  • 1 reply
  • 574 views

Hello, I am working on a game in which a ball will roll down platforms tilted at different angles (independantly, without user input), and I am unsure of how to construct the physics of the ball. I already have the platforms good to go, but I need help figureing out how to get the ball to move down them. I don't want it to bounce, I just want it to roll, and fall down on to the next, and so on. etc... This might not make a ton of sense, just ask if you have any questions. Any help on what the code would look like would be greatly appreciated. Thanks!

This topic has been closed for replies.

1 reply

sinious
Legend
April 3, 2014

There's 2 concepts involved here, velocity (mass/gravity/angle/friction) and collision. The first part is easily faked using simple variables and a frame loop (larger the mass/angle the more the velocity, vice versa, all minus friction). The second part isn't quite so easy.

That said I strongly suggest you simply get a physics engine. Why reinvent your wheel?

Have a look here for plenty of 2d physics engines that will do this for you:

http://tomkrcha.com/?p=1086