Add rotation to the input rotation of a PlayerController

I’ve got a player character that gets attached to an object. That object is moved by via a Matinee. The player is taken on a guided journey through my level. My aim is to allow users to control where they are looking but for the forward of the player character to rotate facing the direction of travel.

I tried SetControlRotation on the player controller every tick but then of course the mouse inputs are overridden, and setting the player character rotation seems to have no effect. Eventually this will be viewed on a HeadMounted display the solution needs to support that.

Edit:

I’ll expand, I’m trying to add some rotation to the PlayerController rotation so they are guided to face the direction they are travelling.

Here’s my attempt, it just spins out of control:

The head mounted display will override and allow you to look around out of the box…

In regards for controlling with mouse input:

thanks for your answer, It helps to know I can add to the controller input globally. I’ve expanded on my original question to be clearer in what I’m trying to achieve.

Please do let me know :slight_smile: I’ve moved on to another feature for now, but will be coming back to this problem shortly. Will also let you know if I find anything out about getting this to work.

If you use actor rotation set to self as the “New Rotation” in the Set Controller Rotation node it will recenter to the position of the character.

The only problem is it snaps to that location instead of slowly rotating to that position. If you want a smooth rotation use RInterp and use Player Controller Rotation as the current and Actor Rotation as the target.

1 Like

Modifying the ControlRotation is the correct way to adjust the camera and view rotation. By default we also match a Character’s Yaw to the ControlRotation, but you can override this by setting “Use Controller Rotation Yaw” to false on the Character. Then you should be able to rotate the Character independently without the ControlRotation trying to override it.

Hi!
Did you came up with a solution?
I’m trying to achieve the same thing.

There is also this tutorial:


made by Daerst on the forums here:

Hi! Thanks for the information.
I have a pawn attached to a “path” actor, i’m not using a character.
I need to make that when the actor rotates, it rotates the pawn so the camera always keep facing forward the direction of the travel.
I came up with this, but when the “base” actor rotates, the pawn starts spin out of control. Here i’m only using the yaw, i would need the same system for the the pitch and roll too.
Thanks!

I’m not sure why you are multiplying the base rotation by delta seconds but that could be why your pawn is spinning out of control. Also try using set actor rotation instead of add controller yaw input.

Hi!
I used the set actor rotation, it worked fine, but i lose the ability to look arround, with the Head mounted display, or the mouse. Is there any way to combine both?

hmm. I’m not 100% sure I understand exactly what you are trying to do so I’m kind of taking a stab in the dark here but. What if you set up the mouse control similar to what is in the third person template.

3946-camera_control.png

you can set up the inputAxis under Edit > Project Settings and then select input under engine on the left.

I’m trying to make a guided journey for my player through a level over a base mesh. So i animate a “base mesh” in matinee and attached a pawn to it. I’m trying to make that the player’s view rotates with the base mesh, and always point foward. But i also need the ability to free look arround the enviroment.
When i use the SetControl it locks the camera in the mesh direction.
I input thelook up and turn, but it’s override by the Set control rotation at every tick.

To add that, imagine as if the player is sat in a roller coaster, they can look around but when the look forward they are always looking in the direction of travel.

Did you came up with a solution?

This has been driving me crazy did anyone ever find a solution?

Imagine the player is sitting inside a car, they can look around freely, but “forward” is always the front of the car, even if the car is turning or changing direction.

Setting the control rotation overrides the player’s inputs, so they can no longer look around, but are forced to look forward in the direction of the car.

Is there some way to add the players inputs on top of the control rotation?

Here’s the solution I came up with:

Get the delta between the moving platform’s previous rotation and its current rotation. Then feed that into the Add Yaw Input node. Seems to work well – the VR POV follows the platform’s rotation while still allowing complete freedom to look wherever you want.