# How do you rotate a character so it's feet is facing a point in the world?

**URL:** <https://forums.unrealengine.com/t/how-do-you-rotate-a-character-so-its-feet-is-facing-a-point-in-the-world/312251>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [March 23, 2015, 2:43pm UTC](https://forums.unrealengine.com/t/how-do-you-rotate-a-character-so-its-feet-is-facing-a-point-in-the-world/312251 "2015-03-23T14:43:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_d71a2fac1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d71a2fac1](https://forums.unrealengine.com/u/anonymous_user_d71a2fac1)\
**Post date:** [March 23, 2015, 2:43pm UTC](https://forums.unrealengine.com/t/how-do-you-rotate-a-character-so-its-feet-is-facing-a-point-in-the-world/312251/1 "2015-03-23T14:43:56Z")

</div>

Hey, i’m working on a small project where i’m trying to do so a third person character(from the template) can walk around on a floating sphere. But i’m having some problems making so that the character rotates so that it’s feet are towards the spheres location in the world so that it can actually walk on it.

I was thinking about doing it like this. This is in the spheres C++ class, it currently has a trigger sphere that it gathers all overlapping actors from and then find the actor that is the player.

```
ACharacter* Player = Cast<ACharacter>(OverlappingActors[i]);
FVector PlayerActorLoc = Player->GetActorLocation();
FVector Direction = GetActorLocation() - PlayerActorLoc;
Direction.Normalize();
    				
FRotator PlayerRot = Direction.Rotation();
Player->SetActorRotation(FRotator(PlayerRot.Roll, PlayerRot.Pitch, PlayerRot.Yaw));

```

This does not currently work as the character just spins weirdly. I also understand that i don’t really want the player to rotate to the sphere as this will cause the character to faceplant the sphere as forward is not where it’s feet are.

Anyone have any idea how i can do so the player always keeps it’s feet towards the sphere?

---

<div class="post-metadata">

**Author:** ![Duncan\_Dam](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Duncan\_Dam](https://forums.unrealengine.com/u/Duncan_Dam)\
**Post date:** [March 23, 2015, 2:50pm UTC](https://forums.unrealengine.com/t/how-do-you-rotate-a-character-so-its-feet-is-facing-a-point-in-the-world/312251/2 "2015-03-23T14:50:42Z")

</div>

Don’t rotate character Roll and Pitch you should be fine, From 1st person view, Pitch is for look up and down, Roll is like you lean left and right, Yaw is what you need to rotate character.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d71a2fac1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d71a2fac1](https://forums.unrealengine.com/u/anonymous_user_d71a2fac1)\
**Post date:** [March 23, 2015, 3:13pm UTC](https://forums.unrealengine.com/t/how-do-you-rotate-a-character-so-its-feet-is-facing-a-point-in-the-world/312251/3 "2015-03-23T15:13:22Z")

</div>

I don’t really understand what you mean. Do you mean like this?

```
Player->SetActorRotation(FRotator(0.0f, 0.0f, PlayerRot.Yaw));

```

Because this just cause the character to spin around what looks like randomly.  
I did also try

```
Player->SetActorRotation(FRotator(90.0f, PlayerRot.Yaw, 0.0f));

```

Which almost results in what i want but only works for the sides of the sphere (if you are looking at it from top down). If you go under or over it wont face the sphere middle anymore.

---

<div class="post-metadata">

**Author:** ![Duncan\_Dam](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Duncan\_Dam](https://forums.unrealengine.com/u/Duncan_Dam)\
**Post date:** [March 23, 2015, 3:42pm UTC](https://forums.unrealengine.com/t/how-do-you-rotate-a-character-so-its-feet-is-facing-a-point-in-the-world/312251/4 "2015-03-23T15:42:15Z")

</div>

oh ok, sorry, didn’t see all your question there. ^^ so basically your character Upward Vector must be same with the PlayerActorLoc - GetActorLocation(), so you can do this.

```
FVector Direction = PlayerActorLoc - GetActorLocation()
FRotator Rot = FRotationMatrix::MakeFromZ(Direction ).Rotator();

```

If not correct try reverse direction.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d71a2fac1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d71a2fac1](https://forums.unrealengine.com/u/anonymous_user_d71a2fac1)\
**Post date:** [March 23, 2015, 3:49pm UTC](https://forums.unrealengine.com/t/how-do-you-rotate-a-character-so-its-feet-is-facing-a-point-in-the-world/312251/5 "2015-03-23T15:49:50Z")

</div>

Sweet, that got it working! Thanks!  
Here is the code if anyone needs it.

```
ACharacter* Player = Cast<ACharacter>(OverlappingActors[i]);
FVector PlayerActorLoc = Player->GetActorLocation();

FVector Direction = PlayerActorLoc - GetActorLocation();
				
FRotator PlayerRot = FRotationMatrix::MakeFromZ(Direction).Rotator();
Player->SetActorRotation(PlayerRot);

```
