# Why does GetViewRotation get crazy when looking backwards?

**URL:** <https://forums.unrealengine.com/t/why-does-getviewrotation-get-crazy-when-looking-backwards/1146268>\
**Category:** Verse\
**Tags:** unreal-engine, unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [April 27, 2023, 2:28pm UTC](https://forums.unrealengine.com/t/why-does-getviewrotation-get-crazy-when-looking-backwards/1146268 "2023-04-27T14:28:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AgentJonesyFN1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AgentJonesyFN1](https://forums.unrealengine.com/u/AgentJonesyFN1)\
**Post date:** [April 27, 2023, 2:28pm UTC](https://forums.unrealengine.com/t/why-does-getviewrotation-get-crazy-when-looking-backwards/1146268/1 "2023-04-27T14:28:29Z")

</div>

Props move very weird when looking backwards using GetViewRotation on them, here’s a video:

[https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/e/c/decb6bbefe31ca6f566a3f2eef4ef56cd53584ed.mp4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/e/c/decb6bbefe31ca6f566a3f2eef4ef56cd53584ed.mp4)

Code Used:

```auto
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters }
using { /UnrealEngine.com/Temporary/SpatialMath }

source_light := class(creative_device):

    @editable
    FollowerProp : creative_prop = creative_prop{}

    DoFollowPlayer()<suspends> : void =
        loop:
            if (PlayerList := GetPlayspace().GetPlayers(), FortniteCharacter := PlayerList[0].GetFortCharacter[]):
                PlayerPosition : vector3 = FortniteCharacter.GetTransform().Translation
                FollowerProp.MoveTo(PlayerPosition, FortniteCharacter.GetViewRotation(), 0.2)             
                
            else:
                break
            Print("Follow")
    OnBegin<override>()<suspends>:void=

        DoFollowPlayer()

```

---

<div class="post-metadata">

**Author:** ![Nman\_Pkr](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nman_pkr/32/1194697_2.png) [@Nman\_Pkr](https://forums.unrealengine.com/u/Nman_Pkr)\
**Post date:** [April 29, 2023, 5:40pm UTC](https://forums.unrealengine.com/t/why-does-getviewrotation-get-crazy-when-looking-backwards/1146268/2 "2023-04-29T17:40:24Z")

</div>

I’m using an educated guess here, but I think what is happening is Gimbal Lock. I think two of your axes are coinciding when you get to a certain view rotation and guessing the Prop to Roll/Pitch instead of yaw. What happens if you use TeleportTo instead of MoveTo?

---

<div class="post-metadata">

**Author:** ![InsanePete](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/insanepete/32/641314_2.png) [@InsanePete](https://forums.unrealengine.com/u/InsanePete)\
**Post date:** [May 1, 2023, 10:10pm UTC](https://forums.unrealengine.com/t/why-does-getviewrotation-get-crazy-when-looking-backwards/1146268/3 "2023-05-01T22:10:12Z")

</div>

Quick speculation here, but given that the Y/Z axis are reversed from the ‘usual’ 3D implementation - is it possible that the gimbal lock we normally don’t encounter except when looking straight up or down (along the vertical axis, unusual in an FPS and often ignored as a problem) is instead happening along the X or Y axis?  
If they’ve copied a standard 3D implementation of these functions without swapping the Y/Z variables, this is what we would expect to see: gimbal lock problems in ‘everyday’ use-cases.

EDIT: I guess I hi-jacked the thread, apologies: Here’s something a bit more practical. Try rotating your ‘following’ model around the Y axis then offset the return value from GetViewRotation to compensate. If it does turn out to be gimbal lock, this will move the lock position and you can try to move it somewhere harmless to your design.

EDIT2: I’ve had strange issues with rotation in general and I made a list of possible causes. One of them is collisions… Is it possible that your following item is bumping into the player collision or some other collision object? That might explain the way it appears to bump around when it goes ‘crazy’ too…

---

<div class="post-metadata">

**Author:** ![Nman\_Pkr](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nman_pkr/32/1194697_2.png) [@Nman\_Pkr](https://forums.unrealengine.com/u/Nman_Pkr)\
**Post date:** [May 1, 2023, 10:42pm UTC](https://forums.unrealengine.com/t/why-does-getviewrotation-get-crazy-when-looking-backwards/1146268/4 "2023-05-01T22:42:32Z")

</div>

What if you store the previous value of GetViewRotation() and the current value to find the difference in yaw between the two rotations. You could use GetYawPitchRollDegrees() Then subtract the current yaw from the previous and apply a local rotation: ApplyLocalRotationZ(DegreesToRadians(YawDiff))

Just would need to make sure the origin of your light is in the correct place for it to rotate the way you want it to.

---

<div class="post-metadata">

**Author:** ![InsanePete](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/insanepete/32/641314_2.png) [@InsanePete](https://forums.unrealengine.com/u/InsanePete)\
**Post date:** [May 2, 2023, 12:24am UTC](https://forums.unrealengine.com/t/why-does-getviewrotation-get-crazy-when-looking-backwards/1146268/5 "2023-05-02T00:24:44Z")

</div>

I’m running some experiments with Rotation and can definitely say:

- there is Gimbal Lock
- it’s aligned with the Vertical Axis
- it doesn’t happen if you use ApplyPitch instead of MakeRotationFromYawPitchRoll  
So the suggestion above will probably work to avoid it… if that is indeed your problem.
