• entries
235
509
• views
172600

# Immovable Object vs the Irresistible Force

133 views

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.

## 1 Comment

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

## Create an account

Register a new account