'Actor Position WS', but I need Actor Rotation WS

Hi, I am creating an imposter UV NPC. I want it to to face the direction of the Rotation XYZ.
How can I get the Actor/Object Rotation WS in a material blueprint?


This will give you the local Z direction.


But maybe you need a simpler setup:

  • getting the Z-axis rotation in a blueprint
  • writing it there to a Material Parameter Collection (it’s a global variable container from which materials can read)
  • then using an ImposterUV node in the material?


To cut to the case I am creating an ARK mod. I’ve replaced the character 's skeletal mesh with a plane which rotates towards the player in order to display the 2D texture correctly. So the solution I was seeking wouldn’t have worked.

The best I can think of right now is determining the angle from two points, but I would need to store a previous Actor Position in order to calculate the angle between the two points. Is there a way to store variables in a material?

It looks like the ActorPosition gives us the location of the whole actor, while ObjectPosition is for individual objects. For example, to visualize, the sphere is attached to the cube here:

Is it possible to get actor orientation/rotation in a similar way that the ActorPosition gives us the position of the parent component? So in this case, on the sphere it would return the orientation of the cube, because the sphere is attached to it.

… Maybe via HLSL…? I’d be grateful for any pointers, if this is possible at all.

I found the solution on this Japanese blog post:

Add a custom node with these contents to retrieve a Float3 containing the object’s rotation in radians (recommend making this a material function):

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

In this case, pi is an argument to the custom node.
To convert to degrees, multiply the result by 57.2958.

Note that if you want to use this in the “RotateAboutAxis” material node, Component Mask out the degrees value of, for example, B (yaw), divide by 360 (RotateAboutAxis uses a 0-1 scale for rotation), and input it into RotationAngle. Add the result of the RotationAngle node to the initial vector that you’re rotating in order to acquire the final rotated vector.

Weird that it’s showing that syntax error. You put the code directly into a Custom node in the Material Editor right? I’m on UE5.1.1 and it’s still working for me.

It also seemed to work for the guy in the other post about this:

Note that there is an issue with the Y value calculation in my original post which he mostly resolved in the above post, although it still doesn’t seem to be perfect.