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
[java]
player.setWalkDirection(walkDirection);
cam.setLocation(player.getPhysicsLocation());
…
shotBlock.getControl(RigidBodyControl.class)
.setPhysicsLocation(cam.getLocation());
shotBlock.getControl(RigidBodyControl.class)
.setLinearVelocity(cam.getDirection().mult(2));//TODO FIX THIS SO THAT IT GOES OUT FROM THE VIEW[/java]
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.
FIX:
[java]
shotBlock.getControl(RigidBodyControl.class).setPhyscialLocation(cam.getLocation()).add(cam.getDirection())); //This will put the object a little bit infront of the player
[/java]
Thanks again.
2 Likes
Yeah, thats one of the major problems with physics, the danger of creating an impossible state
thx for sharing your solution gbluntzer