The Joyride Labs no longer actively work on this project. A lot of the information on this website is outdated. See this blog post to find out more.
Nikki and the Robots

Here we write about Nikki and the Robots development and other news. Be sure to subscribe! Visit our reddit forum and join IRC for even more info!

Moving Platforms

WARNING: This is a development post. So if you're not into programming, you might find it rather boring... although this time, we also have a nice video!
Currently we are working on moving platforms. Everybody who played 2-dimensional platform games knows them and surely we wanted to include them in our game. So we were faced with the question of how our platforms should be modeled, or more precisely, how the behavior of our platforms should be programmed. The naive approach would be to just calculate the position from a given platform path and then set the position every frame. This does not play well (and wouldn't feel right) with a physics engine, though. So we have to come up with a way to control our physical object without being to intrusive. Most of the times, this boils down to manipulating neither the position nor the velocity of an object, but apply a force to it. So, when modeling platforms, we currently have three forces:
  • anti-gravity - Since we don't want our platforms to fall down and just lie on the ground, we apply a force, that is exactly the negative of the gravitational force. At first sight, that sounds very fancy. And of course, it is.
  • drag - This is the force that slows down a moving object in a fluid or gaseous medium. (German) wikipedia says it has either a linear or a quadratic dependence on the velocity of the moving object. (Well, at least approximately.) Of course, Wikipedia only talks about 3-dimensional physics - in heavy violation of their neutral point of view policy ;). So what about 2-dimensional fluid drag? Any ideas? Anybody wants to conduct experiments involving two close glass plates with a fluid and flat objects between them? Sounds like fun. I digress.
  • magical pushing-where-the-platform-should-go force - well, yeah, that's what it is.
This video shows an early version of the platforms:

The lines on the left depict vectors for debugging purposes:
  • yellow is the velocity of the platform,
  • blue the applied drag and
  • red the applied force towards the intended position.
As you can see, the platform is moving rather awkwardly and can't support Nikki's weight yet. So there is still some tweaking to do, to make platforms behave nicely. But we believe that our approach is right: Interfering with a physics simulation while running in order to control its objects is always a bit strange and deus-ex-machina-like. But if you try to realize a concept in a physically sound way, you have the chance of getting something that still feels very natural.
We will talk about this again, as soon as the platforms are looking better!

Tags: , ,

Leave a Reply