I’m using Unity and I’m building an object placement system where you’ll be able to position objects around the player.
I’d like to place objects flush with the ground, parallel to world up, even on slopes, so I’ll use a raycast for that.
How would I limit the distance to
maxDistance? I tried using ScreenPointToRay but the max distance on the raycast makes the movement of the object stop if the raycast doesn’t hit.
As an example, If I’m looking down in front of me, the object i’m controlling should be at that position. However, if I’m looking straight forward into Infinity, the object should only ever be
maxDistance away. If I rotate, the object should follow smoothly.