Lots of coins simulated in Bullet -> coin pusher arcade game

Post Reply
cbuchner1
Posts: 17
Joined: Fri Apr 10, 2009 6:44 pm

Lots of coins simulated in Bullet -> coin pusher arcade game

Post by cbuchner1 »

Hi

here's a quick youtube video showing what I am up to. http://www.youtube.com/watch?v=74C61A-wzaA

UPDATE: check out second posting for HD clip of a working prototype

My goal is to be able to simulate 500 to 1000 coins with Bullet in order to re-create a penny pusher arcade game. Right now things get slow at about 70-100 coins (Dual Athlon MP @ 2 GHz, SSE acceleration, no SSE2 available),

I post here to get some advice regarding the physics. My code is based on the osgbullet sample, except that I use cylindrical objects instead of a sphere (this code sample uses btSequentialImpulseConstraintSolver as constraint solver, btAxisSweep3 for broadphase, btCollisionDispatcher with btDefaultCollisionConfiguration for the collisions).

I opted to make my base units millimeters instead of meters. So the coins have a 5mm radius, 1mm thickness (a 10:1 ratio of diameter vs height - this should be OK I guess). My simulation time step is currently 1/200 of a second.

I ended up using a gravity vector of 9.81 * 100 only - realistically this should be 9.81 * 1000 (i.e. 9.81 m/sec*sec). But when I tried the latter options, the coins started bouncing on the ground uncontrollably. Strangely enough, using only 10% of the earth's gravity appears to look realistic enough. I might stick with this.

When I allow the coins to enter sleeping state, they stop rotating/spinning when their speed gets lower than the sleep threshold, but instead of truly resting they keep vibrating on the ground plane, as if they were held in place by a series of upward impulses. Also I notice that coins stacked on top of each other keep sliding apart, as if the entire coin stack was placed on some kind of shaker mechanism.

It's the "sliding apart" effect that I would like to get under control - it might make the game too easy because coins would just slide off the pusher and might end up getting won by the player. Are there any switches that I could use to reduce the vibration+slide effect?

And finally, which settings might make the physics scale to more coins? Right now I am getting trouble at 70 coins or more, but a real arcade might contain hundreds of those. I could try running the CUDA accelerated broadphase algorithm, but that's only accelerating one piece of the physics puzzle. Is there anything I could try to make this scale better? Multithreading? Changing algorithms? Tweaking some settings? I am open to suggestions.

Christian
Last edited by cbuchner1 on Sun Jun 21, 2009 8:29 pm, edited 1 time in total.
cbuchner1
Posts: 17
Joined: Fri Apr 10, 2009 6:44 pm

Re: Lots of coins simulated in Bullet -> coin pusher arcade game

Post by cbuchner1 »

I claim success! I've got a working physics prototype for a decent sized penny pusher machine. Check it out here.

http://www.youtube.com/watch?v=0bLAq7btZbU&fmt=22

There are about 300-400 coins in the game. Getting realtime performance caused me the biggest headache. The accuracy of the physics is now adaptively tuned to hit a target frame rate of 30 FPS. And if this is not possible then the simulated time just slows down gradually. The coins become a little jittery when the physics accuracy (iteration step frequency) is reduced, sometimes causing them to fall early. But hey, it's still an early prototype.

I've had some unnerving issues with the physics. Those cylindrical coins kept jiggling on any surface they were supposed to rest on. The more gravity I used, the more jiggling I got. It was much worse when the coins rested on kinetic objects. So I turned these surfaces (pusher, coin plate, ramp) into dynamic objects and the jiggling was very much reduced.

Lots of further optimization is possible, for example using the multithreaded solver or CUDA broadphase (also the CUDA solver when available).

From here on out, it's all about adding game mechanics (user controlled coin injection), keeping a coin balance, adding different methods for injecting coins. We can use coin slots at the top of the back panel from where the coins drop down through an obstacle course - or a rail that the user can point towards the intended drop spot). Oh, and... sound will be needed. Later I could be adding some electronic gizmos (bonus games, jackpot) on the machine. Bonus prizes could be put on top of the coins. I've seen cheap watches, rings and other stuff placed on top of the coins in Chinese game arcades. When they finally fell out, the player got to keep em.

Christian
Post Reply