How to make the camera not rotate?

I’m making a top down game and I want the camera to not rotate at all when the player rotates. I know in unity you keep the camera separated and update the camera position in a script and I’m sure you can do that in UE4 as well, thing is this is gonna be a split-screen game and I don’t know if UE4 allows split-screen if the camera is not in the blueprint.

I tried this code:

void AMyCharacter::moveRotate(float Value)
	topDownCamera->AddLocalRotation(FRotator(0.0, 0.0, -Value));

to see if I could cancel out the rotation but it still rotated (although it did rotate slower than the parent)
I tried setting the relative rotation and the world rotation to zero and it didn’t work, I tried setting the camera as the root component and it didn’t work either.

I just want the camera to not rotate when my character rotates.

Any help will be appreciated, thanks.

P.S I’m using the A and D keys to rotate my character

I haven’t worked with splitscreen, but I assume that the camera would be dependent on both Characters. I suspect you’ll require some kind of camera manager which handles the logic of where the camera should be pointing.

In any case, in single player you can do it as follows:

You could override CalcCamera in your Character class to get the behaviour you want, e.g.

void AYourCharacter::CalcCamera(float DeltaTime, FMinimalViewInfo& OutResult)
	OutResult.Rotation = ...

Try this instead: Place a USpringArmComponent in the hierarchy between the camera component and its parent. Then set bInheritYaw to false.

You can use a spring arm in your component hierarchy to prevent it from inheriting its rotation from its parent.

I might have a solution by making a separate camera class and then just activating the camera for the specific players.