[Noob question] Moving a pawn relative to the world space

Resupply8672
Thu, 09 Nov 2017 07:10:51 +0000
C++

Hi, I’m really struggling to get this to work. Would really appreciate a nudge in the right direction.

I have an actor, which can move up/down and left/right. When this actor is rotated 90deg clockwise, up is becoming left.

I can’t get it to stay moving forward, based on it’s current rotation (amazing diagram below).

My current implimentation is as follows:

void AZumoPlayer::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	PlayerPawnInput.Sanitize();

	//Move the Player
	FVector DesiredMovementDirection = FVector(PlayerPawnInput.MovementInput.Y, PlayerPawnInput.MovementInput.X, 0.0f);
	FVector CurrentPos = GetActorLocation();
	CurrentPos.X += DesiredMovementDirection.X * MoveSpeed * DeltaTime;
	CurrentPos.Y += DesiredMovementDirection.Y * MoveSpeed * DeltaTime;
	SetActorLocation(CurrentPos);
}

Any help is appreciated. I’m new to ue4 c++ and really having a lot of trouble working this one out.

4 posts - 3 participants