Can't get actor rotation

Im trying to get the rotation axis of an actor in the game but it’s not working.

105372-ue4bp_1.png

Output Yaw is always 0.0

Does it work if you do not collapse the graph?

No i’ve tried it all open, in macro, different GetRotation nodes. Nothing works.
In the GetActorRotation his Return Value i do get a warning that the Variable is not in scope.

If you get this warning in the blueprint debugger, thats ok. The thing is that those “Get” nodes (that have no execution pin) are executed when they are first needed. Could you submit a screenshot showing the first usage with an execution pin?

105374-ue4bp_1.png

Ah, that clears everything up now. As a default, you have the yaw at 0. when you press “R” you rotate the door and when you press “R” again you would expect the door to rotate back. This wont work in that case, since:
You set the WorldRotation of the StaticMeshComponent BUT you query (get) the ActorRotation of the parent actor; and you are never changing the rotation of the door actor (as said, only the rotation of the staticmeshcomponent inside.

So, instead of doing “SetWorldRotation” on the staticmeshcomponent (last picture), do “SetActorRotation” on the SM_Door and it should work.

The door his default Z is 90.
But the BP thinks the default is 0.
So in short, 0 is not higher than 90
thus it opens.
360 > 90? close the door.

Your solution didnt work, it still opens though :slight_smile:

What do you mean with “default Z”? In the Base Blueprint or the Instance? Where exactly is it 90? In the StaticMeshComponent inside the SM_Door Blueprint, or is the SM_Door Blueprint rotated that way?

I just quickly tried it myself, it works as expected. Probably you changed the rotation inside the StaticMeshComponent only? Then your SetWorldRotation node would be correct, but the GetActorRotation would be wrong (and you would need to use “GetWorldRotation (StaticMeshComponent)” there.

105381-ue4bp_4.png

Current setup, still it only opens.

So, ok, i am a bit confused by the logic now tbh.

Lets say that the current rotation of the door is 90.
When i now press “R”, your “Door Rotate” will return “90” and “false” (since 90 is not bigger than 90).
We will no get into the “false” branch leading to “Close the door”.
Inside “Close the door” you are doing a loop from “90” (input value) to 90 (last index) and set this rotation → Nothing will change and when you press “R” again, nothing happens again.

I would recommend to rethink the logic you are doing. Sometimes its easier to start this from the beginning again.

Please also note, that you dont need to make a loop here; I guess you are trying to smooth the opening and closing of the door, but the whole loop will just happen in the same frame. If you want to smooth the movement of the door, use something like a timer and do a LERP to the desired target value.

Also its not really the best pattern to have such things inside the Level Blueprint. Usually you will want this logic in your own Door Blueprint so it is reusable.

For your convenience:

Create a new Blueprint derived from actor. Lets call it BP_Door.
Add a StaticMeshComponent and assign it your door StaticMesh.

Now create 2 variables inside: “isOpen” of type boolean, and “targetYaw” of type float. Now try to replicate the following graph inside the EventGraph (you will need to create some custom events):

Place this in your level.

Now open your level blueprint and get in a reference to your new BP_Door inside the level and do the following:

105384-bp_door_lvl.png

This has been tested and works. Hope this helps. Cheers!

Reworked the whole thing, this works.