Currently in my top-down game, I am calculating the distance between the character vector and the mouse location vector. If the length is > 1000, I am wanting to display the decal under the mouse cursor along the line between the actor and mouse location, but 1000 length away from the actor, instead of under the mouse.
How would I accomplish this?
Basically I am wanting to find the point 1000 units away from the actor, but on the line between the actor and the mouse.
The method is completely geometry independent. No depth was specified in the request so I’ve used player’s current location rather than ground level. Depending on how it will work in the game (elevation, landscape complexity, slopes… this may need to be adjusted by shifting Plane Origin).
In short:
create an up-facing plane at player location
trace from the camera to the mouse cursor projected into the world
when the trace hits the plane, we get both magnitude and direction of the resulting vector
only show the result if vector length is greater than specified distance
An alternative here is to line trace to get hit’s surface data. But again, this depends on what the end goal is. Do include more detail if the original solution is not suitable.