FPS Game, SetViewWithBlend Camera Control

Hi,
I have been recently trying to learn the Unreal Engine by modifying the C++ FPS Example project. What I am trying to do is implement Aim Down Sights by using the SetViewWithBlend function to transition the player’s camera down to a camera I have on the gun. I have separated the gun into its own weapon class (instead of having it as a child component of the first person arms mesh) in order to successfully use this function. It works fine except for one issue. The attached Gun actor does not pitch up or down with the character’s mouse input, but it does turn left and right for some reason. The character still does pitch up and down just fine, as when I exit the Aim Down Sights camera, my view snaps to where the player was supposed to be aiming.

The parent->child component and actor relationships are: PlayerCapsuleComponent → PlayerFPS_Camera → PlayerArmsMesh → SeparateGunActor.

I’ve tried numerous things, but have yet to be able to fix this issue. Is there anything that I happen to be doing wrong here? I am not sure if there are any screenshots or additional details that would help better describe this situation, but please let me know there is something that I can show to help add clarity for my issue description.

Thanks.

Managed to come up with a quick and dirty solution, which I will describe for those who may benefit from it. I am not sure at all if it is the best, but it appears to work which is good enough for me.

  • First, in your Character Blueprint, make sure both “Use Controller Rotation Pitch” and “Use Controller Rotation Yaw” are both checked. This will rotation your whole player object in the direction your camera is facing. This is why I call this a dirty solution because it just doesn’t feel right to me. The collision box will probably be screwed up because of this.

  • Next, in the Player’s Move Forward function, use the following code INSTEAD of the AddMovementInput(GetActorForwardVector(), Value); line that is typically used.

    FVector norm = FVector(GetActorForwardVector().X100,GetActorForwardVector().Y100,0.f).GetSafeNormal();
    AddMovementInput(norm, Value);

This will find the vector direction, in the X and Y axes, that will ignore the player’s Pitch rotation, successfully preventing the movement speed decrease when looking up or down due to the X and Y values of the Actor forward vector being smaller in those instances.

If anyone has a better solution, please let me know. I would definitely be interested in hearing it.

The first point solved my problem, you saved the day. Many thanks!