Trace and Decals

  • 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.
I was working on a bit of script that invloves simply taking the rotation of the actor and tracing then spawning a decal at the hitlocation. Im not exactly sure what code to use to get the trace function to work.

Code:
var vector X, Y, Z, StartTrace, EndTrace, HitLocation, HitNormal;

function postbeginplay()
{
placedecal();
}



function placedecal()
{

	GetAxes(rotation, X, Y, Z);
	StartTrace = Location;
	EndTrace = StartTrace + vector(rotation) * 10000;
	Trace(HitLocation, HitNormal, EndTrace, StartTrace, True);
	spawn(class'BlastMark',,,HitLocation);

}

I think I should be using the HitNormal somehow to set the rotation of the decal. . .

Any suggestions on whats wrong with the code?
 

butto

Red Orchestra Coder
GetAxes is used to obtain vectors for the individual X, Y, and Z components of particular vector. It works as follows:

local Vector MyVector, X, Y, Z;
MyVector = Vector(Rotation);
GetAxes(MyVector,X,Y,Z);

That will take the rotation and convert it into its subelements. You could then do something like this:

Velocity = 600 * X;

That would change your velocity to 600 in the X direction. Usually GetAxes is not needed and you only have to manipulate vectors in ways like this:

Velocity = 600 * Vector(Rotation);
Velocity.Z += 500;
Velocity *= 500;
Velocity = 40 * vect(1,0,0);

GetAxes is used when you want to translate some vector to be relative to some rotation, as in the following example:

local vector StartTrace;
local vector EndTrace;
local vector X, Y, Z;
GetAxes(Pawn(Owner).ViewRotation, X, Y, Z);
StartTrace = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z;

In this case, the vector decribing the fire offset is made relative to the player's view rotation so that the bullets get fired in the right direction from the right place.

I hope that clarifies this.
 
wow thanks:) that clarifies the question. I put the trace function to good use in the following code attempting to have a player leave footsteps behind. It works great except that the footsteps are all in really weird directions. I thought setting their rotation.yaw to that of the player would fix this but its doesnt. Can anyone see why its not working?


Code:
simulated function print(pawn p)
{
	local vector HitLocation, HitNormal, StartTrace, EndTrace;
	local rotator RotNormal; //rotator of hitnormal

	local Decal D;
	local rotator rot;
	local actor e;

	rot.yaw = 0;
	rot.pitch = -16383;
	rot.roll = 0;
	StartTrace = p.Location;
	EndTrace = StartTrace + vector(rot) * 128;
	e=Trace(HitLocation, HitNormal, EndTrace, StartTrace, True);
	RotNormal = rotator(HitNormal);
	RotNormal.yaw = p.ViewRotation.yaw; //set rotnormal.yaw to players yaw

	if(e == level)
	{
		D=spawn(class'scorch',,,HitLocation,RotNormal); //spawn rotnormal instead of hitnormal

		D.texture = PrintTextures[cnum];

	}



}

Thanks for your help
 

butto

Red Orchestra Coder
EndTrace = StartTrace + vector(rot) * 128;

Shouldn't that be a minus if you're looking down, no? Just a thought.

I would try using the player's rotation instead of view rotation and see if you have better luck. The other thing you have to keep in mind is that the image itself could be facing the wrong way.