Hello.
I know Box2d is a 2d engine (as the name suggests 😉 ) but I'd like to fake a third dimension (height). I've got a catapult projectile launching from top to bottom (birds eye view) and everything works fine. What I'd like to is calculate the theoretical height of the object after launch. Usually, I'd calculate a 3D trajectory like so:
How can I convert this into Box2D? At the moment, the X axis is left-> right, Y is top->bottom and the theoretical Z-axis will be height (coming out of the screen). Since I'm launching my projectile via ApplyLinearImpulse, I'm not sure what the best way to calculate the Z-axis value would be and how to tie it in with the simulation. I'd be grateful is anyone had any suggestions on how to do this (or a better way)?
Thanks in advance
I know Box2d is a 2d engine (as the name suggests 😉 ) but I'd like to fake a third dimension (height). I've got a catapult projectile launching from top to bottom (birds eye view) and everything works fine. What I'd like to is calculate the theoretical height of the object after launch. Usually, I'd calculate a 3D trajectory like so:
Code:
float zVal= Math.Cos(angle);
launch.X = (float)(Math.Cos(angle) * zVal);
launch.Y = (float)(Math.Sin(angle) * zVal);
launch.Z = (float)Math.Sin(angle);
launch.Normalize();
launch.X = (float)(Math.Cos(angle) * zVal);
launch.Y = (float)(Math.Sin(angle) * zVal);
launch.Z = (float)Math.Sin(angle);
launch.Normalize();
How can I convert this into Box2D? At the moment, the X axis is left-> right, Y is top->bottom and the theoretical Z-axis will be height (coming out of the screen). Since I'm launching my projectile via ApplyLinearImpulse, I'm not sure what the best way to calculate the Z-axis value would be and how to tie it in with the simulation. I'd be grateful is anyone had any suggestions on how to do this (or a better way)?
Thanks in advance