Monday, December 3, 2012

Balancing Physics

This is how the game currently looks like.

It turns out that balancing the game physics for flying robots will be a long journey. In this post, I will explain one example, Flight height.

First of all, there are two factors influencing how fast a robot takes off: Its weight (depending on amount of parts used) and amount of propellers attached. This allows for a huge range of possible combinations from robots that are too heavy to fly ( :P ) to very lightweight constructions that lift off immediately.

Especially for lightweight flying robots it was at first very easy to just literally skyrocket in a couple of seconds, until they were too high to see the ground - not only making it very difficult to keep control over cruise height, but also making orientation close to impossible (No ground in sight -> "Where am I?"). Hence, it was necessary to somehow limit the flight height.

So I decided I need to scale something that influences how high one can fly depending on robot height. I made up a function for a scaling factor: 1 - [(Max Height - Current Height) / Max Height]

This returns a value from 1 when the robot is grounded to 0 when it has reached the maximum height. After some experimenting, I found out the best thing to scale by this factor is the vertical speed when flying. As a result, more lightweight robots still lift off faster than more heavy ones, but none of them can get over the maximum height, since their speed will be multiplied by zero.

Graph visualized by Google
To make the whole vertical slowdown a bit more smooth, I multiplied that factor by itself, so now it approaches zero like the graph in the picture.

No comments:

Post a Comment