How to implement First Person Shooter camera?

Wow this looks great!
This dynamic fov control must be very useful when you move around the world, but in my case, models just sit and only move their upper body to see the world around them, so I might not employ your great method to my app.
But thanks for showing me pretty good demo! :grinning:

What I wanna do looks like this playground.
Is there any better way to do this?

Thanks for your attention.

1 Like

It looks great I think you should go with it

Offset the local position of the camera forward so that the view does not feel like it is in the head of the model, or hide the head (don’t know if this is possible).

That is exactly what I am trying to solve.
I think, to properly make the camera stay exactly the same position relative to the head (maybe on the forehead of the model), the camera need to move inside the local space of the head (actually the neck bone).
So I want the camera to use the local space of neck bone as its world space.

You know the complicated thing is this,

  • I want the bone to follow the rotation of the camera

  • and I want the camera to follow the position of the bone (and also move some distance relative to the local space of the bone)

What why? That is not normally how you would do it but ok…

Why do you need the camera attached to the mesh and not vice versa?

Am I missing something?

I thought, it is said that I can control universal camera by mouse, so if the bone follow the motion of the camera, that would be good.

Maybe the best solution is

  • Parent the bone to the camera, and somehow implement some code to move the bone from mouse.

Not necessarily, in fact it might cause jittery jumpy movements, and you are gonna have to constantly update your up vector anyways on the camera.

Re read my post about the height and animations reliant on basic math.

A simple solution given what you would want to lerp the cameras position to the bones absolute position. But then you are gonna have to figure out a way to establish forward.

Thank you for your replys Pryme8!
I like the way how universal camera rotates as I keep clicking on the canvas and move the cursor around.

  • The distances that the cursor’s moved along x (and y) axis from the position of mouse-on event affects the camera’s rotation around y (and x)

Do I need to implement this distance-to-rotation conversion by myself (which I think I can but not the best at)?

So the solution would be

  1. Make the camera a child of the head mesh which is attached to the neck bone.
    So the parent->child relationships becomes [neck bone]->[head mesh]->[fps camera(not universal camera anymore)].

  2. Implement the cursor’s-moved-distance-to-rotation-around-x-and-y-axis conversion by myself, and use that calculated rotation to rotate the neck bone.

But why? The person in first person will never see it unless you are using a reflection probe and do a mirror or something, but even then I belive convention would be to render a different model to the reflection probe then what you are rendering to the first person camera.

1 Like

Remember we are only trying to simulate real life models not emulate them.

There is always a creative solution. The main consideration to have here is what is your final product trying to achieve, a realistic biometrics system or just a representation to fool the brain?

Thank you for your advices Pryme8!
I’ll do some work on it and post it here later.

Did you ever see this?

1 Like

Alot of FPS implementations use 2 models

An “arm rig” that the player camera has parented to it to give the illusion that you are carrying a gun and have it pointed wherever you are looking:


And a full body model that other players / reflection probes/ your second camera “sees” you as, similar to the dude mesh you are trying to rig your camera to. You can have your arm and third person models be on separate rendering layers, so that the cameras can be configured to properly ignore the right type of model.

Is there a specific reason why you don’t want to use an arm rig for your camera?

4 Likes

Hey I am sorry for being late, but I implemented what I wanted to do.
Here is the result playground.
What do you think?

3 Likes

Looking good buddy! I bet you could tweek that quite a bit and add some limits in and it will work for you.

I want to thank you Pryme8 for helping me along this implementation :smile:
Someday I wanna help other newbies just as you did.
Thanks a lot!

3 Likes

That’s the only price we want you to pay :wink:

2 Likes