issue with "GetHitResultUnderCursor" in a space game (infinite skybox)

Hi everyone,

I have an issue with my cursor/camera behavior in a top down spaceship game. I’m currently using the following BP on a tick function to offset the camera to wherever the player’s cursor is. It works perfectly except when my cursor points toward the skybox.

As the game is in early stage I have a basic checker floor below my ship, but eventually it will be removed. When my mouse goes outside the checker floor into the blue infinite skybox, my camera starts shaking really hard as it seems to try to go between my ship and I guess infinity.

One dirty solution I thought about was to make a huge invisible floor across my entire map that only collides with the mouse, but I’m pretty sure there is a more elegant solution.

Thanks a lot for your help !

The skybox you’re using ignores trace results for the visibility channel. The built in sky atmosphere is ue does not have any collisions on it. So yeah, adding a gigantic invisible mesh might be the answer. You can also drag out that red pin that says blocking hit and plug that into a branch. If it’s true, you clicked on something, if false, then you didn’t, you can get your cameras forward direction, multiply by 3000, add your spring arms location to it, and set that as your spring arms new location

1 Like

you could just use GetMousePositionInViewport and calculate the offset from center of the screen.

or maybe DeprojectScreenToWorld and use the direction multiplied by a fixed amount

1 Like

Thanks a lot for your inputs. I tried a couple things a so far I haven’t been able to make something work.

For the time being, I’ll just make a big invisible plan a child of my actor, acting as a collider with the cursor. This is a bit dirty but it’s probably better than having a huge 2D plane across the entire map.