The Blobbiest of Physics

As the next step in my little home brew physics engine, I was to create a simple game. Something that uses the capacity of my engine for 3D physics, is interactable with the player, and has a win or lose condition.

I decided to make a blob game in which the player must avoid AI blobs for as long as possible.

The gameplay is simple, WASD to move, spacebar to activate 10 seconds of “double movement speed”. Collect the powerups in the corners when they spawn to get another use of boost. A new AI unit spawns at the same time a new boost powerup does.

Although it may be difficult to see from the top down angle of the game camera, the units are spherical blobs, made up of 10 spherical particles. 9 outer particles, with a single core particle. The core particle is connected to every outer particle by a rod, which every outer particle is connected to each other outer particle by a spring. This creates a deformable blob to roll around the world.

To move the player, and the AI blobs, I simple find the highest particle making up the blob and apply force in the direction I want the blob to move in.

for(auto aiIter = m_aiBalls.begin(); aiIter != m_aiBalls.end(); aiIter++)
{
   avgPos = V3(0,0,0);
   highest = (*aiIter)[0];
   for(int i = 1; i < (*aiIter).size(); ++i)    
   {      
      if((*aiIter)[i]->GetPhysics()->GetPosition().y > highest->GetPhysics()->GetPosition().y)
      {
         highest = (*aiIter)[i];
      }
      avgPos += (*aiIter)[i]->GetPhysics()->GetPosition();
   }
   avgPos *= 1.0f/(*aiIter).size();
   highest->GetPhysics()->AddForce((centerPos - avgPos).normalized() * aiMovementForce);
   if((centerPos - avgPos).length() <= 4)
   {
      m_health--;
   }
}

This creates very elastic movement from the blobs, as they are pulled along by the top and thus roll in the direction I want them to travel in. To achieve this effect I also had to apply a .7 coefficient of friction to the floor, so that the particles which touched the floor “stuck” to it, rather than just sliding. I also remove 1 health from the player every frame for each AI blob within 4 units.

Leave a Reply

Your email address will not be published. Required fields are marked *