Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Immovable Object vs the Irresistible Force

Sign in to follow this  


If Odin could do anything, could Odin create an object so heavy that he couldn't move it? Clearly not.

An object that was fully immobile would require an infinite mass, thus requiring an infinite amount of energy to create.
Even if an object was not infinitely heavy, but just maximally finitely heavy - in that all of the energy in the universe were put into constructing it, there would be no more energy left over to move it, or for Odin to exist in the first place.

This is not merely a philosophical argument - it applies to games, too. Infinitely heavy objects aren't consistent with
physics engines unless they are completely static. Since an infinitely heavy object would require infinite energy to move,
it's impossible. Small wonder, then, when two impossible objects don't interact nicely.

Today I was making my character roll around a spiked ball, and I rolled it into a trap - a vertical group of spikes that can shoot out of the wall, ala the 1st scene in Raiders of the Lost Ark.

Now, in Ancient Galaxy, the character normally does not receive impulses from physical objects, to avoid getting stuck or getting shot off very fast if a heavy object touches him. This also prevents the character from ever being stuck behind a pile of heavy objects.

The doors and traps don't receive impulses either, to prevent them from getting stuck and impeding gameplay.

So, when my 'infinitely heavy' character pushes against a massive spiked ball, which pushes against an 'infinitely heavy' set of spikes - who wins?

In my case, the set of spikes was being slowly pushed out of the wall. This was due to a bug, but when I fixed it, I still had some issues to solve.

Part of the problem is that my physics code doesn't look ahead in time, but instead moves objects, then tries to fix penetrations. When two infinitely heavy objects penetrated, I was moving them each 0.5 of the penetration distance apart. You can't use the relative masses in this case for obvious reasons. This was causing the spikes to shift when they were pushed by the character.

I modified the code to look at each object's speed relative to the total speed of both objects, and use that to scale the penetration distance. This way, if one object is the one moving ( ie your player ), he gets moved out of the object, and the other object gets to stand still.

This solved that problem, but created another one. Now, if the player stands still, he can impede doors, which used to push him aside out of the way.

To restore the old behavior, I will have to add priorities. If both objects share the same priority, I will use speed method, otherwise, I will use a floating point priority, and only move the object with the lower priority.

Update - added the priority system, and it works great.
Sign in to follow this  

1 Comment

Recommended Comments

Wow, an abbreviated physics engine too. Is there anything your game won't have?

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!