I am trying to make an actor that can place objects in the world some distance in front of him. I always want the object to be 1000 units in the horizontal axis in front of the actor but placed on the ground.
Below I have added an image where the green triangle is my actor and the red square is the desired placement of my object.
First, I find a starting point that is 1000 units in front of the actor by getting his forward vector.
The methods I have tried:
- Line trace from starting point straight downwards. This works for cases 1, 2 and 4, but doesn’t work for case 3 because the starting point is already below terrain.
- Line trace from xy coordinates of starting point but + 999z (higher up). This works for cases 1, 2 and 3, but doesn’t work for case 4 because the ceiling intercepts the trace.
- Method 1 for cases 1,2,4 but Line trace from starting point straight upwards used only on case 3. This doesn’t work because the trace start is inside terrain and instantly registers a hit instead of going to the surface. I do not know if it is possible to get the first surface point from inside static meshes.
I am out of ideas how to achieve this behavior regardless of terrain. Any hints and ideas would be appreciated.