Search code examples
unreal-engine4unreal-blueprint

Have a UI waypoint arrow rotate in the direction of the to next checkpoint, relative to the player in UE4?


I've been working on developing a UI-component that always points to the next checkpoint as the user plays through the game. My issue is that I don't know how to update the rotation of the arrow in relation to the player and the next checkpoint. With my current setup, the arrow rotates erratically, or spins in circles. I believe the nodes I want to use are the "Find Look at Rotation", "RInterp To", and "Add Rotation."

Here's what I have so far: https://i.sstatic.net/PsocW.jpg

My player actor is a pawn, the checkpoint is an empty actor class that I have hidden when the game is being played, and the waypoint arrow is a static mesh floating outside the playable environment that I setup a 2DCaptureComponent and green screen, such that I can update the rotations of the waypoint arrow during the game, and the UI will automatically update.

-- Update --

I was able to set the initial rotation of the waypoint arrow correctly using this setup: https://i.sstatic.net/7kN7W.jpg

I changed the "Add Rotation" node to "Set World Rotation", and added -90 to the Yaw (to offset the initial orientation of the waypoint arrow). However, after setting the initial rotation, it no longer updates the rotation after the player actor rotates. Any insights?

-- Edit --

Here is the rotation angles of 1) the waypoint arrow in the blueprint capture class, and 2) the rotation of the blueprint instance as it exists in the world: https://i.sstatic.net/PXgly.jpg


Solution

  • Use Set World Rotation instead of Add World Rotation.

    You should use Get Player Pawn then Get Actor Location. And for rotation, I think you can do Get Player Camera Manager then Get Actor Rotation if you want the camera's rotation. Or, if you want the pawn's rotation, you should use Get Player Pawn then Get Actor Rotation.

    And to handle the offset you need, implement your arrow as an actor, with the mesh as a Static Mesh Component which is a child of the root. You can apply the offset you need specifically to the mesh, so that it points in the direction of the actor's local forward.

    Source: @denmonz