Hey! Im trying to implement topdown input movement, where the player always walks towards the mouse cursor while using the wasd movement.
I did the “look at” (in this case at the mouse cursor) in blueprint:
https://impetus-games.com/uploads/cgblog/id6/05_Actor_Rotation_BP.jpg
Now, i use the standard move forward input in c++:
void ACharacter::MoveForward(float Value)
{
if ( (Controller != NULL) && (Value != 0.0f) )
{
// find out which way is forward
FRotator Rotation = Controller->GetControlRotation();
// add movement in that direction
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
AddMovementInput(Direction, Value);
}
}
Now the problem is: when i dont move, the character is facing the mouse cursor how it should, but ofc when i move with wasd, it walks not towards the mouse direction, but instead in the typical fps/3rd directions. I know that i need to declare the function, but nothing works properly.
I´ve tried already a lot of stuff but i can´t find an solution. Would be great if someone could help! Hope everything is clear. Thanks already so much!