Ultra fast 32 direction physics
Author: | ben mercer
|
Submitted: | 12th July, 2005
|
Views: | 6135
| Rated: |
|
|
Hi all,
I have lately been annoyed at how if I make a custom movement system with improved physics, it always goes into complete game slowdown if i have more than about 30 objects with forces acting on them simultaniously.
I have since found a cool and easy way of utilising the MMF preset "bouncing ball" movement to create some reallistic 32 direction physics (don't hate me just yet, read on).
You simply have your X and Y vectors like you would in any physics engine, and then using advanced direction object, translate xy vectors into a speed and direction (using the dist and dir between objects functions respectively). Make sure you have advanced dir set up to work in 32 directions.
The advantages of doing it this way:
-No CPU eating fast loops are required to detect collisions in between mmf loops
-No complex, CPU eating collision normal detection loops are needed to find the direction in which an object moves off in after collion with a surface (bouncy ball movement does this for us; you must, however make sure that the new xy velocities are translated back after a bounce using the cos(dir)*velocity/sin(dir)*velocity)
-On the whole it is much faster, i have got it running perfectly smoothly with over 200 bouncing balls on the screen.
The only disadvantages are pretty obvious, really:
-Objects are bound to 32 directions
-Objects speed values must be integers between 0 and 100
That's about it. I know i should really make an example but ive just finished my GCSEs, i can't really be bothered to do jack at the moment, look out for an examp soon though.
|
|
ben mercerPossibly Insane
Registered 11/07/2004
Points 2538
|