CharacterControl and Cam Projectile not shooting out in the right direction[Solved]

My Code is trying to shoot out a Node based on the direction of the camera.

Im basically trying to do what the HelloCollision example does where it shoots the cannon balls at the brick wall.

I have added a player CharacterController so that the camera behaves like a FPS with physics

The problem is when I “Shoot” the projectile only goes in one direction and does not use the cameras dirction







.setLinearVelocity(cam.getDirection().mult(2));//TODO FIX THIS SO THAT IT GOES OUT FROM THE VIEW[/java]

1 Like

Thanks for the reply. That is some good info.

It turns out my problem was that I was setting the location of the shot object inside the player physics object. So I was literally shooting myself in the head and it was banking off the player physics object in all but on direction.



shotBlock.getControl(RigidBodyControl.class).setPhyscialLocation(cam.getLocation()).add(cam.getDirection())); //This will put the object a little bit infront of the player


Thanks again.


Yeah, thats one of the major problems with physics, the danger of creating an impossible state

thx for sharing your solution gbluntzer