Download

Clamping a 2d point based off the position of a 3d vector?

Hello

So, i have a 2d “cursor” (X and Y float variables, that hold how much the player has moved their stick Left/Right, Up/Down, i.e Y=50, X-50 )

I add these Pointer X and Pointer Y to the End of a linetrace, so that the linetrace X and Y change depending on the player stick input

I then clamp my Pointer X and Y based off previously’acquired values by printing their positions when at the screen edges

This works fine if my camera is pointed completely down, the trace stops at the camera edges and no extra input can be added

However becouse my camera is slightly angled becouse of the perspective the trace ends up looking like this

(Another issue is that, Since im only clamping it based off the distance from the center of the screen to the edges, if i move my player to either camera side, then the point wont get clamped properly )

Also, becouse the trace starts off the player location, if i move my player to the right the trace (while clamped ) continues to trace off into infinity