The First Test: Gravity

The first of my summer experiments comes to a close.

Resorting to messing around with this in my spare time, it has taken much longer that it perhaps should have. As I write this I’m struck by the niggling feeling I never truly explained what the purpose of the test was.

As I played my way through the catalogue of games I have at home, I occasionally stumble across mechanics and such that make me really question how the result was achieved. I become filled with thoughts on how it could be tweaked to create a new product of greater interest, or something new altogether.

One such example that has really stuck with, as mentioned already, is “Super Mario Galaxy”s planet levels, which allow you to walk all the way around their surface. As it stands Mario Galaxy is a family orientated platformer, but how would the same feature work under a puzzle solving environment, or in competitive shooters?

In summary, the real aim of project is much of an ‘asking if we could, not if we should’ case.

In my mind I achieved what I set out to do. But judge for yourself:

Spherical Planets TestThe rough process used first involved removing the gravity of Unitys physics engine, then replacing it with my own gravitational field for each planet. The field itself is a trigger collider component attached to the sphere, wherein every object inside gains a constant force directing them to the centre of the planet.

// The key component of scripting the gravity is the OnTriggerStay method
void OnTriggerStay(Collider object)
{
  Vector3 newGravity = planetPosition - objectPosition;
  if(/*object doesnt have constant force*/)
  {
    //add constant force component to the object.
  }
  //set constant force = newGravity
}

Upon leaving the field the constant force component is removed, and that’s all there really is too it. At least from what I want to achieve at the current time.

Advertisements