Game Development Community

Stack of objects wobble non-stop

by Dave Calabrese · in Torque Game Builder · 12/28/2005 (9:12 pm) · 6 replies

I have a set of fxStaticSprite2D blocks that have collision and physics turned on, with a constant force to simulate gravity. I want these blocks to fall to the ground, bounce off of each other once or twice and settle into place as gravity takes over.

Well, I tried changing the physics properties various ways, and cannot get the blocks to stay still. It looks a lot like Brownian motion from a chemistry class. Even the bottom row of blocks that are on the immovable ground wiggle back and forth.

Does anyone know if I'm doing something wrong with the settings, or are the multiple collisions confusing the system?

Here are some of the parameters that I modified (the values shown are just one test set):
friction = 1.0;
restitution = 0.0;
relaxation =1.0;
density = 0.1;
forceScale=1.0;
damping = 1.0;
ConstantForce = "0  100";
linearVelocity = "0 10";

-Dave C.

#1
12/29/2005 (12:46 am)
After doing some more testing, it looks like there is some sort of a constant impulse being applied to the objects. I have my code setup to create a pyramid of blocks, which fit neatly together. I then sit there and watch it. At first nothing happens.... then after about a minute, the blocks begin to wobble. After another 10 or 20 seconds, they begin to violently wobble and shake and the pyramid starts to crumble apart, almost as if there was an earthquake. Then the wobbling stops, and the blocks just slowly slide left and right.

What could possibly be causing this? There are no programmed impulses being applied to the objects... they're just sitting there!

Edit: Spelling error.
#2
12/29/2005 (5:29 am)
Getting rigid-body objects to stack can be a complex problem. Well, the problem is easy but a "generic" solution can be damn hard. There are many ways to solve this problem and you can find many examples on the net. Different solutions include making the objects wake/sleep, ordering the processing according to the direction of gravity (which is completely arbitrary in T2D as each object can have a constant force), yada yada.

You also need to enforce much stricter processing via iterations of collision-det/reposonses. This slows things down drastically but does solve other things such as collision-tunnelling issues related to instantaneous overlap-processing.

Changing the fundamental way collisions are processed and enforcing lots of overhead just so you can stack things was something we easily decided wasn't worth the effort.

This "jitter" problem, especially related to stacking objects is one of the "bigger" issues in rigid-body physics. In the end, we want a fast game-engine and have demoted the rigid-body to cool-responses only. This means you can have things like tumbling blocks (perhaps simulating a building collapsing) or have grenades bounce/tumble as the player throws it and may other cool effects.

In the near future, I can see us putting in sleep/wake processing as this has performance benefits globally. I'm not so sure about the next stages considering the "other" stuff we've got on our plates though.

I hope this explains a little of what is involved.

- Melv.
#3
12/29/2005 (3:15 pm)
The 'problem' that I see is more of an abuse of the physics system.

if t2d was meant to be a physics simulator then i would generally think that Dave's problem would be a valid concern. but t2d isnt a physics simulator, it's a game engine that happens to have a pretty kick-ass physics subsystem built in.

So keeping this in mind, i think it is a valid option for you (the game developer) to 'fudge' physics/collisions/etc so that they are more performat. Not only is it valid, I strongly belive this is the most desirable course of action.

A mistake i see with a lot of my peers (IE: newbie game developer wannabes) is that they want to re-create/simulate the universe. one guy even wanted physics on a per-molocule scale. That's great and all, but we are here to make games, right? And as such, we need to make tradeoffs that make sence, and what makes getting the job done easier.

--------------
So dave, my suggestion would be for you to turn off the physics on your pyramyd until it is collided with an external object. At that point, turn on the physics for X seconds, and then after that interval X, start dampining the physics by +Y% every second. then once you are at 100% dampening, disable physics again.

of course that is just a suggestion, you will have to figure out a way of implementing something similar that makes sence for your situation.

-Jason
#4
12/29/2005 (3:48 pm)
Actually, your suggestion is exactly what we ended up doing. =)

I've been doing game dev for about 2 - 3 years now, and I'd have to say I have found that almost everything you see in games is "smoke and mirrors". All the cool stuff you see and that happens in a game level is nothing more than a designer illusion, the physics you see in many games is also an illusion (heck, when we did TubeTwist we had to tweak and modify things so even though the game uses true physics, there are still portions that we tweak in real-time to make the simulation more fun).

I've also seen many newbies wanting to make absurd simulations, including myself. I've been wanting to do video games since I was 14 (I'm 26 now), and back then I was designing a game that had something like 1000 multiple dimensions. Today I look back and laugh at my very amature self back then, now knowing how insane and absurd that is.

A good game is nothing but an illusion - no matter how you accomplish what you accomplish, it should be fun and seamless for the player. =)

-Dave C.
#5
12/30/2005 (1:16 am)
That's a pretty good assessment Dave, it made me think exactly of how stage-magic is. To the viewer, well-performed magic is, well, magic. Impressive and awesome. To the magician, the stuff is often so hacked, low-budget and obvious it is a wonder anyone ever believes the illusion for a second. :)

Ignorance is bliss! ;D Well, for the audience at least.

I think one factor is that the "it just works" quotient has risen quite high lately, all the Torque products (and especially T2D) do some amazing work on behalf of the would-be developer, that it is sooo easy to want more and more of that magic. But as developers, we gotta step behind the curtain and know the limitations, be creative in solving the challenges.
#6
12/30/2005 (2:14 am)
Jason, Dave and Luke make Melv Happy. ;)

- Melv.