Getting a Vector In front of the player

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Brood_of_Evil

Selene's martyr
Nov 3, 2001
147
0
0
45
Look outside your window!
Visit site
Do this:
Code:
local vector x, y, z, SpawnLoc, Start;
local int Distance;

Distance = 200;

GetAxes(ThePlayer.ViewRotation, X, Y, Z);
Start = ThePlayer.Location + CalcDrawOffset();
SpawnLoc = Start + vector(ThePlayer.ViewRotation) * Distance;

Spawn(class'YourClass',,,SpawnLoc);

Of course ThePlayer will be the reference to the player you want to spawn the object in front of. Distance is the distance between the player and the spanwed object (in unreal units). You can increase or decrease "Distance" to make it farther, or closer to the player. If you need an aproximate distance in feet, just divide "Distance" by 16.
 

Brood_of_Evil

Selene's martyr
Nov 3, 2001
147
0
0
45
Look outside your window!
Visit site
Yep! Good call I forgot about that...so do this instead:
Code:
local vector x, y, z, EndTrace, StartTrace, HitLocation, HitNormal;
local int Distance;
local actor A;

Distance = 200;

GetAxes(ThePlayer.ViewRotation, X, Y, Z);
StartTrace = ThePlayer.Location + CalcDrawOffset();
EndTrace= Start + vector(ThePlayer.ViewRotation) * Distance;

A = Trace(HitLocation, HitNormal, EndTrace, StartTrace);

if(A == None)
     Spawn(class'YourClass',,,HitLocation);