Simple ship movement with Box2D (Part 2 – Changing the limits)

In Part 1 there were a few things I needed to adjust in how I was using Box2D for my application. This post is basically about trying those changes out.

What did I learn?

Sometimes I find that when you are not sure how to do one things it gets much easier to do the other things that you do know how to do. Last week I set out to do five things with Box2D. I knew how to do most of the API related changes but I am less sure how I actually want to tune the ships. So instead of thinking about it, I just went ahead and did the API related changes and it went really well. My lesson for trying new things is Don’t think, just try. Playing with scale in Box2D worked really well and was easy enough to tune without understanding.

Changing the scale by a factor of 10

I went through the code and scaled the size of everything down by 10. A few small issues later and I was up and running at light speed! With the original impulse/speed values it was like WAY more than 10 times faster. If you tune with a clamp you end up with lots of values that would go over that clamp in an unconstrained environment. I had to go through and scale things down until it was starting to look correct. With the new scale my ship could easily travel at 2000m/s (thats 2 KILOMETERS per second!). It turned out that at my orginal scale the correct speed for the right space/speed size was around 300m/s. I’m going to toy around with that as the top speed.

Tuning correlated systems is challenging

The other changes that I made were: moving to using torque to turn the ship and using the built in damping in Box2D. After changing all of these variables I found out that they are all related to each other. I just don’t know the specifics of how yet. Given enough time the ideal thing would to to sort out what the combination of changing the scale (which changes the mass), adding damping and converting to using torque does to the overall ship balancing. Instead I just kept tuning with my Lua tuning file and found ranges that worked for me. I know that in the future I’m going to have trouble working with force since as I change the size of my ships the mass changes. I have to find a way to fix the mass to keep the balancing simple. You can avoid understanding for awhile, but in the long run you need to understand how things work to build on what you have.

Last weeks hit list updated

  • How do I set the mass of the ship? – I think this one is going to be fairly easy.
  • If I change the scale from 1 unit = 1m to 1 unit = 10m, what other variables do I need to change for mass?
  • Convert from setting angular velocity to applying torque
  • Determine how I want to tune the acceleration/force curve over time – I’m thinking that I will use a force vs. current speed function to tune this with a fixed mass per ship.
  • Use Box2D native dampening rather than my own hacked functions

What is next

Physics

  • Determine how damping works (top speed seems limited by this)
  • Implement an engine system that will let me tune the ship experience
  • Determine how to set the mass

Polish

  • I’m dying to add particle FX for a reward on explosions and gun shots
  • Starting to worry that I might not be able to do good missile trails in the PopCap framework

Art

  • It has been to long since I’ve exercised the right side of the brain: Colors? Particles? Who knows…

So I’m not sure what I will be doing this week. You will have to wait and see.

Advertisements
This entry was posted in Technical and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s