I’m currently trying to a make an actor in an Editor Preview Scene rotate towards a position the user clicks on. This is fairly simple while in game and PIE as Player Controllers have many useful functions such as Get Hit Result Under Cursor and Deproject Screen Position To World to go about this. However, outside of PIE and runtime there is no Player Controller to convert mouse position to world space.
All of Unreal’s functionality to do this appears to rely on a Player Controller, so is what I’m looking to accomplish impossible or am I going about this incorrectly?
auto client = (FLevelEditorViewportClient*)GEditor->GetActiveViewport()->GetClient();
if (client != nullptr) {
}
You can try doing that to get the viewport and the “client.” If you look up FLevelEditorViewportClient you can see it has some functions that might be useful. The most relevant one is probably GetCursorWorldLocationFromMousePos.
Thank you for that direction! I wasn’t working in a LevelEditorViewportClient and completely missed that function. It was helpful to see how UE4 was doing it!
In the end I calculated the SceneView and used DeprojectFVector2D to get WorldPosition and WorldDirection from a Click Position.