I'm trying to fire cubes from the camera origin, using the cameras direction as the firing line. I would like to be able to alter the amount of power delivered in the shot with an int.
After looking though various bits of code found on the web, the following seems to be what I am looking for.
obj.body.applyCentralImpulse(Vector3);
Where Vector3 giving the forces in the X,Y,Z
The following gives the direction the camera is looking at
Vector3 dir = cam.direction;
how can I combine the dir and the required force?
many thanks.
This is how it works for me:
float force = 10.0f; //but any value that works for you
Vector3 dir = normalize(cam.origin + cam.direction) * force; //suppose your camera moves around
body->applyCentralImpulse(dir);