void AMyCamera::Move(const FInputActionValue& Value)
{
const FVector2D DirectionValue = Value.Get<FVector2D>();
FVector Forward = GetActorForwardVector();
AddMovementInput(Forward*12, DirectionValue.Y);
FVector Right = GetActorRightVector();
AddMovementInput(Right, DirectionValue.X);
UE_LOG(LogTemp, Warning, TEXT("IA MOVE TRIGGERED"));
}
My intent is to build an RTS style camera. I am getting movement in the left and right dorection. However, when I push W to go forward, the camera moves in the direction of the Red arrow, which is not what I want, and not what I’d expect when I called “GetActorForwardVector”. Could someone help?
There isn’t enough information here to answer this properly.
A vector isn’t an angle… it’s a vector.
You’ve said what you don’t want, but what do you want? The forward vector of what?
Where are you calling this function from?
I know this is your first post, but you need to be specific.
A camera is not an Actor, but an Actor Component, so GetActorForwardVector
will get the forward direction of the actor that the function is being called from, and not the forward direction of the camera. If you want the forward direction of the camera, you would get it like this:
UCameraComponent* CameraComponent = FindComponentByClass<UCameraComponent>();
if (CameraComponent)
{
FVector ForwardVector = CameraComponent->GetForwardVector();
}
However, my code should actually give you the behaviour you don’t want, so something isn’t making sense with your post.