FPS style camera

Hello,

I’m trying to move through an environment I made. I’ve got a problem though with the basic camera. the movement of this camera is nowhere near easy to use when moving and looking around.

My scene exists out of:

  • A camera
  • The environment

What I want the camera to do:

  • moving the mouse left turns the camera left
  • same more other movement of the mouse
  • W,A,S and D move the camera forward, left, back and right
  • the left and right (A&D) strafe instead of turning the camera.

Eventual extra things:

  • the camera has a fixed position above the environment (1,8m)
  • the camera can’t move through the model(s)
  • the camera ‘actor’ can move up a stair, but can’t move up a tree or wall
  • the camera ‘actor’ can jump

I’ve tried a lot of things to make the camera do this and I guess it has to do with the ‘Roaming Ralph’ example, but I just can’t get my head around it.

extra question:
has Panda3D only got one camera type?

Panda3D has one camera type, I believe yes. But, if you turn off the default mouse navigation (using base.disableMouse() ) you can do whatever to the camera you want.
You can then just move base.camera around as you want it, make it interactive based on arrow keys or mouse, or anything you like. There’s plenty of documentation about this, also on the forums.

Yeah but there’s a problem with that. Almost any camera system uses advanced trigonometry to calculate angles and coordinate-changing. I’m not a pro at these things. I just can’t get my head around it.

panda allows very conventient way of altering positions and rotations.
you can set rotations/positions relative to other nodes, even to the node itself.
so if you want your camrea to rotate 5 degrees just do
base.camera.setH(base.camera , 5 )
will make your camrea rotate by 5 degrees. same with positions.
like pro-rsoft already mentioned you need to disable the default camera.mode first with:
base.disableMouse()

But what if I want the mouse to rotate the camera? doesn’t base.disableMouse() make that impossible?

so to achieve what i want it would be something like:
on mouse moving left: base.camera.setH(base.camera , 5)
on mouse moving right: base.camera.setH(base.camera , -5)
on mouse moving forward: base.camera.setV(base.camera , 5)
on mouse moving back: base.camera.setV(base.camera , -5)

base.disableMouse() is misnamed–it doesn’t actually disable the mouse, it just disables the default mouse behavior. You are then free to program your own mouse behavior.

There are plenty of examples posted in the forum from people who have implemented FPS-style cameras, and yes, it does involve code sort of like that.

David

could you hand me one example link? the search thingie on the forum doesn’t work for me as ‘FPS style’, ‘FPS shooter’ ‘first peron shooter’ and things like that haven’t yet found me a snippet or something.

https://discourse.panda3d.org/viewtopic.php?t=4068
might be what you’r looking for