How do make player face forwards where the follow camera is looking? 3rd person shooter

I’m making a shooter and I want the player character mesh (not bothered about blending just yet) to simply face the direction the camera is facing.

I have already set up a recticle on screen as well as made a projectile spawn point in front of the player. Left button is shoot, right button is to aim. Currently the right button makes the recticle appear.

How do I make the player face forwards when I right click?

If you want the player to face the same direction as the camera, you need to copy the Z rotation of the camera into the player controller.

So, in your player, you have a reference to the camera, get the forward vector and split it so you access only the Z.

Then use the SetControlRotation node to change the player Z rotation.

( You can do a GetControlRotation to get the current player rotation, again split it, keep the X and Y and only set the Z ).

Sorry, not at a machine right now, this is about as specific as I can be…

I’m managed to make it face forward when I right click like this. Where do I go from here to make sure the player faces the same direction while I hold right button?

Very good :slight_smile:

You can also just put a GetWorldRotation directly on the camera.

Like I say, to rotate the player you need to use SetControlRotation :wink: so just do a GetPlayerController, pull a pin and do a SetControlRotation, but only in Z.

I think that should do it…

thanks. but now I have the issue of turning speeds. I’m playing around with rinterp but nothing seems to be working :confused:

This is what I managed to do to make it work, however when I use set control rotation instead of set actor rotation, it doesn’t work. Why is this? The actor still rotates towards where the camera is facing which is what I wanted.

I then realised I could just add the option of set controller rotation yaw for when I held down the right mouse button which is the intended effect where the player only faces forwards. I wanted, and would turn off when let go.

Any tips on interp speeds when I right click? because the player instantly snaps to where the camera is facing.

You’re doing very well, despite my foggy guidance ( I’m STILL not at a machine… ).

I’ll have another go, but it’s a bit difficult without the engine in front of me.

You’re on the right track with interp. I -might- have be wrong about set control rotation, it might affect the camera too in 3rd person, I can’t recall.

Anyway here’s the way to do it:

You do get the correct Z from the camera and you feed that into the actor rotation, but you can’t just set it, you have finterp it, as you had already figured.

You only need finterp, because you’re only fixing on axis.

Finterp works by taking two main inputs, one is the value of **now **( an actual sample, like camera rotation ), the other is a FIXED target of where you’re trying to get to, here, the camera Z.

So, the main concept is two things:

  1. when you click, set a variable with the Z you’re trying to get to - that’s all, no other stuff

  2. On Tick, you do the finterp. As the **from **do a get camera rotation and take the Z. As the **to **use the Z you calculated in 1)

So whenever you click, the target gets changed, and constantly on tick, the finterp works to correct the player orientation.

Tell me how you do…

EDIT: That’s one of the problems with your graph there.The TO on the interp isn’t fixed.