Hey, guys.
So I've got this problem where I'm trying to predict where an object is going to land in my Box2D world after applying a certain angle and velocity to it. Think of the aiming line in a pool game, or Peggle, or one of those artillery games. Any idea how this could be done?
I can think of two ways of doing it...
1. The "close enough" way: Estimate how my object is going to travel in the Box2D world using some simple "object accelerating in one dimension" math.
Pros: Would probably work pretty well for simple cases where gravity travels straight down and I want to see where my object travels after being launched.
Cons: Predicting anything after the first collision would be nearly impossible to match up with what Box2D actually does.
2. The "Totally insane but I kinda want to try it" way: Create a second b2World object that's a clone of the first world. Run it for several steps and just observe where my object would travel in that parallel world.
Pros: Would be very accurate. Plus, I like the idea of creating parallel dimensions
Cons: Seems like a lot of work. And I'm lazy.
3. Some much simpler way that I haven't thought of.
Any ideas?
So I've got this problem where I'm trying to predict where an object is going to land in my Box2D world after applying a certain angle and velocity to it. Think of the aiming line in a pool game, or Peggle, or one of those artillery games. Any idea how this could be done?
I can think of two ways of doing it...
1. The "close enough" way: Estimate how my object is going to travel in the Box2D world using some simple "object accelerating in one dimension" math.
Pros: Would probably work pretty well for simple cases where gravity travels straight down and I want to see where my object travels after being launched.
Cons: Predicting anything after the first collision would be nearly impossible to match up with what Box2D actually does.
2. The "Totally insane but I kinda want to try it" way: Create a second b2World object that's a clone of the first world. Run it for several steps and just observe where my object would travel in that parallel world.
Pros: Would be very accurate. Plus, I like the idea of creating parallel dimensions
Cons: Seems like a lot of work. And I'm lazy.
3. Some much simpler way that I haven't thought of.
Any ideas?