So I’ve been slowly taking my first steps into C++ programming in Unreal and there’s one thing that I really can’t find a fix anywhere. I can’t change the camera sensitivity with C++, I could do it in Blueprints or in the engine’s input settings but I really wanted to be able to change it in C++ if that’s even possible.
Hey @Assassin3712. How are you using your camera? The usual way to moving a camera actor is by using a Lerp function between the current camera position and the desired camera position.
For example if your camera is following you character, you probably would have an offset between your character’s location and where you want to place your camera. In this case, your DesiredLocation would be the CharacterLocation + CameraOffset.
In c++ it would look something like this:
AActor* ActorToFollow; // Actor being tracked by the camera
float CameraSpeed; // Speed applied to the interpolation
float CameraArmLength; // How far away do you want your camera from your target
FVector CameraOffset; // Vector from target to the desired camera location
AMyCamera::UpdateLocation(float DeltaSeconds)
{
FVector DesiredLocation = ActorToFollow->GetActorLocation() + CameraOffset * CameraArmLength;
FVector NewCameraPosition = FMath::VInterpTo(GetActorLocation(), DesiredLocation, DeltaSeconds, CameraSpeed);
SetActorLocation(NewCameraPosition);
}
Keep in mind that there are several ways of manipulating your camera, this is just one of them. If you want to have a different behavior you can still use an interpolation like the one used here to control the movement speed of your camera.
I should have been more precise in my question, I’m sorry.
I’m doing a FPS Shooter game and I’m using the FPS Template, so I already have a camera set up and everything. The thing I want to change is the camera’s sensitivity like the speed at which I can move the camera with the mouse.
Although your explanation wasn’t what I was looking for, it actually helped me understanding another thing I was thinking about, thanks.