Get result under cursor in construction script

Hey,

I have a project with a square grid that actors can be placed on, and when I place an actor in the world while using the editor I’d like it to snap to the nearest grid position to the mouse cursor, allowing me to place the actors accurately and also cache the index of the grid node for later use. Unfortunately the ‘Get Hit Result Under Cursor by Channel’ function requires a player controller and of course there isn’t one available when just using the editor, so I can’t call it. There is a more generic line trace function but I can’t find any way to get the mouse position without a player controller.

Is there a way to either get the mouse position during construction or get a player controller during controller, or alternatively another place I can put this functionality that’s more suitable?

Thanks.

Why don’t you use the location of your newly placed actor? You know your grid and you know the non-snapped position of your actor so rounding it to the nearest grid cell should be easy. This should also work while dragging the actor around as there will always be the non-snapped location available during your construction script.

You’re right, that’s exactly what I could do and it’s such an obvious and simple solution I have no idea how I didn’t think of it myself!

Thanks very much.