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

**URL:** <https://forums.unrealengine.com/t/noob-question-moving-a-pawn-relative-to-the-world-space/409132>\
**Category:** C++\
**Tags:** relative-location, get-actor-right-vect, unreal-engine, question, CPP, vectors\
**Created:** [November 9, 2017, 7:10am UTC](https://forums.unrealengine.com/t/noob-question-moving-a-pawn-relative-to-the-world-space/409132 "2017-11-09T07:10:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Resupply8672](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Resupply8672](https://forums.unrealengine.com/u/Resupply8672)\
**Post date:** [November 9, 2017, 7:10am UTC](https://forums.unrealengine.com/t/noob-question-moving-a-pawn-relative-to-the-world-space/409132/1 "2017-11-09T07:10:51Z")

</div>

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).

![219585-untitled.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/6/a/76ad232558cefb2c5804720bd06317fa3dca9d6d.jpeg)

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.

---

<div class="post-metadata">

**Author:** ![Firefly74](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Firefly74](https://forums.unrealengine.com/u/Firefly74)\
**Post date:** [November 9, 2017, 12:31pm UTC](https://forums.unrealengine.com/t/noob-question-moving-a-pawn-relative-to-the-world-space/409132/2 "2017-11-09T12:31:35Z")

</div>

i would rotate "DesiredMovementDirection "

```
FVector DesiredMovementDirection = FVector(PlayerPawnInput.MovementInput.Y, PlayerPawnInput.MovementInput.X, 0.0f);    
DesiredMovementDirection =GetActorRotation().RotateVector(DesiredMovementDirection)

```

that should work ( you might have to swap your X and Y though )

---

<div class="post-metadata">

**Author:** ![Resupply8672](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Resupply8672](https://forums.unrealengine.com/u/Resupply8672)\
**Post date:** [November 11, 2017, 10:27am UTC](https://forums.unrealengine.com/t/noob-question-moving-a-pawn-relative-to-the-world-space/409132/3 "2017-11-11T10:27:26Z")

</div>

Dude, I forgot to reply when I implemented this, but this works flawlessly. Thank you so much.

I would’ve thought you could add movement in relation to the pawn using AddActorLocalLocation() [or something along those lines] but this didn’t seem to work when I tried it.

---

<div class="post-metadata">

**Author:** ![SpoiledEagle254](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SpoiledEagle254](https://forums.unrealengine.com/u/SpoiledEagle254)\
**Post date:** [April 20, 2024, 6:12am UTC](https://forums.unrealengine.com/t/noob-question-moving-a-pawn-relative-to-the-world-space/409132/4 "2024-04-20T06:12:44Z")

</div>

Thank you! Great answer, this just saved me another 2 days of testing!
