Help needed with Laser sight class

  • 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.

Silver_Ibex

Member
Feb 27, 2001
654
0
16
I’m working on a mold braking “laser sight” style aiming system mutator, it uses code based on the Agent X laser code and the “Laser sight” mutator by Glen Sharman that I downloaded from ModSquad.

So far it looks really sweet and works beautifully. Though there are several features that still need added before it’s finished:cool:

I need it to change to a different texture when it hits a target/pawn, and the draw scale needs to also increase, basically I’m having a small dot crosshairs turn into a large circle to encircle the target pawn.

Can “simulated” be used to modify the function so only the owners will be able to see their own “laser aimer” and if so, which function should be the simulated one?

If this would not affect it then how can I make it so only the owner can see it???

If it does not hit anything in between, then the laser dot needs to spawn at a fixed distance to hang in the air. Which part of the “start trace” “end trace” needs to be modified to get this rang limit???

Below is the original unmodified class so you can see what I’m talking about.

class LSight expands TournamentPickup;
//Laser sight object for Laser Sights mutator - Glen Sharman, 2001
//Texture, sound and original concept - Jon Bartram (aka Mr White)

var ldot LD;



#exec TEXTURE IMPORT FILE=Textures\pdot.pcx NAME=LaserDot


function Activate()
{
GoToState('Activated');
}


state Activated
{
function BeginState()
{
LD = Spawn(Class'LDot', Owner);
bActive = true;
}


function Tick(float DeltaTime)
{
local vector X, Y, Z, StartTrace, EndTrace, HitLocation, HitNormal;


if ( Pawn(Owner).IsInState('FeigningDeath') && bActive )
{
LD.Destroy();
bActive = false;
}

if ( !bActive && !Pawn(Owner).Weapon.bMeleeWeapon && !Pawn(Owner).IsInState('FeigningDeath') )
{
LD = Spawn(Class'LDot', Owner);
bActive = true;
}

GetAxes(Pawn(Owner).ViewRotation, X, Y, Z);
StartTrace = Pawn(Owner).Location + CalcDrawOffset();
EndTrace = StartTrace + vector(Pawn(Owner).ViewRotation) * 10000;
Trace(HitLocation, HitNormal, EndTrace, StartTrace, True);
LD.SetLocation(HitLocation);
}


function EndState() //destroy laser dot if player dies
{
LD.Destroy();
bActive = false;
}


function Activate()
{
GoToState('DeActivated');
}
}
 

Brood_of_Evil

Selene's martyr
Nov 3, 2001
147
0
0
45
Look outside your window!
Visit site
Simple really:

first you need to call PostBeginPlay() in the LDot actor and set bOnlyOwnerSee to true:

class LDot expands Actor;
//Laser dot object for Laser Sights mutator - Glen Sharman, March 2001

simulated function PostBeginPlay()
{
bOnlyOwnerSee = true; //**This mean only the owner can see the sight**
}


Then we modify the LSight class, check the comments with **'s:


class LSight expands TournamentPickup;
//Laser sight object for Laser Sights mutator - Glen Sharman, 2001
//Texture, sound and original concept - Jon Bartram (aka Mr White)

var ldot LD;


#exec AUDIO IMPORT FILE="Sounds\zoom.wav" NAME="ActLS" GROUP="Pickups"
#exec TEXTURE IMPORT FILE=Textures\pdot.bmp NAME=LaserDot

function Activate()
{
GoToState('Activated');
}


state Activated
{
function BeginState()
{
Owner.PlaySound(sound'ActLS', SLOT_None, Pawn(Owner).SoundDampening);
LD = Spawn(Class'LDot', Owner);
bActive = true;
}


function Tick(float DeltaTime)
{
local actor TargetedActor; //**Create an actor object**.
local vector X, Y, Z, StartTrace, EndTrace, HitLocation, HitNormal;

if ( Pawn(Owner).Weapon.bMeleeWeapon && bActive )
{
LD.Destroy();
bActive = false;
}

if ( Pawn(Owner).IsInState('FeigningDeath') && bActive )
{
LD.Destroy();
bActive = false;
}

if ( !bActive && !Pawn(Owner).Weapon.bMeleeWeapon && !Pawn(Owner).IsInState('FeigningDeath') )
{
LD = Spawn(Class'LDot', Owner);
bActive = true;
}

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

//**The Trace function returns an actor type variable.**
TargetedActor = Trace(HitLocation, HitNormal, EndTrace, StartTrace, True);
LD.SetLocation(HitLocation);

if(TargetedActor.IsA('Pawn')) //**Verify that the actor is a Pawn**
{
//**Yes it's a Pawn**

LD.DrawScale = <New DrawScale>; //**you can change the drawscale here**
//**call SetDisplayProperties to change the texture**

LD.SetDisplayProperties(STY_Translucent,
Texture'<New Texture>', //**new texture goes here**
false,
false);
}
else //**Else, if there's not an actor at the end of the trace, reset the LDot tp it's default values**
{
LD.DrawScale = LD.Default.DrawScale;
LD.SetDisplayProperties(LD.Default.Style,
LD.Default.Texture,
false,
false);
}
}


function EndState() //destroy laser dot if player dies
{
LD.Destroy();
bActive = false;
}


function Activate()
{
GoToState('DeActivated');
}
}


state DeActivated
{
function BeginState()
{
Owner.PlaySound(Sound'ActLS', SLOT_None, Pawn(Owner).SoundDampening);
LD.Destroy();
bActive = false;
}
}


As for the distance limit, if you modify the following:
EndTrace = StartTrace + vector(Pawn(Owner).ViewRotation) * 10000; //**notice the 10000**

If you lower the 10000 you might be able to adjust the maximum distance of the LDot, you can even make a configurable variable so the user of your mutator can adjust this to it's liking.
I hope that helps good luck with your mut :cool:
 
Last edited:

Silver_Ibex

Member
Feb 27, 2001
654
0
16
The problem is that I need the aimer to work while the Behindview is set to true
The laser sight works great in first person, though now it disappears when in third person view, I need a way to tell it the third person camera is it’s owner
Here is the bit of the code where the camera gets setup in the character class.


event PlayerCalcView( out actor ViewActor, out vector CameraLocation, out rotator CameraRotation )
{
ViewActor = Self;
bBehindView = true;
CalcBehindView(CameraLocation, CameraRotation, 200);//create a camera 200 units behind the player
}
The HUD info is still displayed when Behindview is turned on, so it must be possible.
 
Last edited: