# Get Actor x, y, z rotation angle in shader

**URL:** <https://forums.unrealengine.com/t/get-actor-x-y-z-rotation-angle-in-shader/155362>\
**Category:** Rendering\
**Tags:** unreal-engine\
**Created:** [December 21, 2020, 2:08am UTC](https://forums.unrealengine.com/t/get-actor-x-y-z-rotation-angle-in-shader/155362 "2020-12-21T02:08:45Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![DotBow](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DotBow](https://forums.unrealengine.com/u/DotBow)\
**Post date:** [April 5, 2023, 5:21pm UTC](https://forums.unrealengine.com/t/get-actor-x-y-z-rotation-angle-in-shader/155362/7 "2023-04-05T17:21:02Z")

</div>

[mpxc](https://forums.unrealengine.com/u/mpxc) this piece of code helped me a lot, thanks!  
However, the Y value was wrong so I modified code to work properly (UE5.1.1)

```auto
float3x3 WtoL = LWCToFloat(GetPrimitiveData(Parameters.PrimitiveId).WorldToLocal);
float3 R = float3(
atan2(WtoL[2].y,WtoL[2].z) * -1.0,
atan2(WtoL[2].x,WtoL[2].z),
atan2(WtoL[1].x,WtoL[0].x)
);
return R < 0 ? 2 * pi - abs(R) : R;

```

---

_[View the full topic](https://forums.unrealengine.com/t/get-actor-x-y-z-rotation-angle-in-shader/155362)._
