# How do I get my upvector to match a surface normal?

**URL:** <https://forums.unrealengine.com/t/how-do-i-get-my-upvector-to-match-a-surface-normal/373378>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [October 14, 2016, 9:34pm UTC](https://forums.unrealengine.com/t/how-do-i-get-my-upvector-to-match-a-surface-normal/373378 "2016-10-14T21:34:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JimmothySanchez](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JimmothySanchez](https://forums.unrealengine.com/u/JimmothySanchez)\
**Post date:** [October 14, 2016, 9:34pm UTC](https://forums.unrealengine.com/t/how-do-i-get-my-upvector-to-match-a-surface-normal/373378/1 "2016-10-14T21:34:51Z")

</div>

I’ve created a floating pawn that the player can move around the map. I’m already doing a line trace from the pawn to the ground underneath, so I’ve go the returned normal from that trace. I want to rotate the pawn so that the up vector matches the surface normal, but I can’t figure out how I would do that. Basically if the pawn starts to go up a ramp I want the front of pawn to raise to match the angle of the ramp. I only want to change the pitch and the roll of the pawn. I don’t want to affect the yaw. Right now the ship is physics based, so I’d rather add a rotation each frame than set any rotation. If there’s a way to do this in blueprints it would be preferable.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_21ba43ad](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_21ba43ad](https://forums.unrealengine.com/u/anonymous_user_21ba43ad)\
**Post date:** [October 15, 2016, 2:03am UTC](https://forums.unrealengine.com/t/how-do-i-get-my-upvector-to-match-a-surface-normal/373378/2 "2016-10-15T02:03:12Z")

</div>

I would do something like this:

 ![110950-normal.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/3/5/b351a2cedf3e4ebef261be8a93dbd3d36fc554dc.png)

Ignore the trace parameters those are for a Sphere I had in my world positioned at 0,0,0

---

<div class="post-metadata">

**Author:** ![JimmothySanchez](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JimmothySanchez](https://forums.unrealengine.com/u/JimmothySanchez)\
**Post date:** [October 15, 2016, 10:10pm UTC](https://forums.unrealengine.com/t/how-do-i-get-my-upvector-to-match-a-surface-normal/373378/3 "2016-10-15T22:10:44Z")

</div>

The problem with that solution is that it sets the rotation instead of adding forces, and it doesn’t take into account the current yaw, that I want to keep, but I thin it’s a step in the right direction. Thanks
