RuneStorm
http://www.runestorm.com/forums/

How to orient third person lasers?
http://www.runestorm.com/forums/viewtopic.php?f=69&t=74653
Page 1 of 1

Author:  Sergeant Kelly [ Sun Jun 08, 2008 11:43 am ]
Post subject:  How to orient third person lasers?

In my quest to fix up the remaining bugs in my mod, I noticed that the laser of the AH104 does not point directly forward in third person.

Image

Does anyone know how to code in the correct vectors for the laser target? Here's the code I'm using currently.

Code:
simulated function Tick(float DT)
{
   local Vector HitLocation, Start, End, HitNormal, Scale3D, Loc;
   local Rotator X;
   local Actor Other;

   Super.Tick(DT);

   if (bLaserOn && Role == ROLE_Authority && Handgun != None)
   {
      LaserRot = Instigator.GetViewRotation();
      LaserRot += Handgun.GetAimPivot();
      LaserRot += Handgun.GetRecoilPivot();
   }

   if (Level.NetMode == NM_DedicatedServer)
      return;

   if (Laser == None)
      Laser = Spawn(class'BallisticV21.LaserActor_Third',,,Location);

   if (bLaserOn != bOldLaserOn)
      bOldLaserOn = bLaserOn;

   if (!bLaserOn || Instigator == None || Instigator.IsFirstPerson() || Instigator.DrivenVehicle != None)
   {
      if (!Laser.bHidden)
         Laser.bHidden = true;
      return;
   }
   else
   {
      if (Laser.bHidden)
         Laser.bHidden = false;
   }

   if (Instigator != None)
      Start = Instigator.Location + Instigator.EyePosition();
   else
      Start = Location;
   X = LaserRot;

   Loc = GetTipLocation();

   End = Start + (Vector(X)*5000);
   Other = Trace (HitLocation, HitNormal, End, Start, true);
   if (Other == None)
      HitLocation = End;

   Laser.SetLocation(Loc);
   Laser.SetRotation(Rotator(HitLocation - Loc));
   Scale3D.X = VSize(HitLocation-Laser.Location)/128;
   Scale3D.Y = 1;
   Scale3D.Z = 1;
   Laser.SetDrawScale3D(Scale3D);
}



Any help would be greatly appreciated.

Author:  Kaboodles [ Sun Jun 08, 2008 2:54 pm ]
Post subject:  Re: How to orient third person lasers?

I don't have access to your mod for the moment, so here's a few questions:

-Did you make the AH104 not dual-wield-able, and thus not a BallisticHandgun class?
-If so, did you change its attachment class to be subclass of BallisticAttachment instead of a HandgunAttachment?

If not, do so, and add this variable

Code:
var     BallisticWeapon      myWeap;

and this function

Code:
function InitFor(Inventory I)
{
   Super.InitFor(I);

   if (BallisticWeapon(I) != None)
      myWeap = BallisticWeapon(I);
}


to your attachment class, and replace all instances of "Handgun" to "myWeap".

That should fix your problem.

EDIT: What character model is that? Crysis suit?

Author:  Sergeant Kelly [ Sun Jun 08, 2008 5:40 pm ]
Post subject:  Re: How to orient third person lasers?

Whoops, I completely forgot about the handgun class.
Thanks, it works now. :)

So this code gives the weapon a new class and sets the laser to use that specific class? It looks pretty sophisticated.


That model is the Quake 4 trooper from Filefront. It comes in a nice pack with the Strogg and some other guys. I'll get a link up as soon as my internet speeds back up.

Author:  Kaboodles [ Sun Jun 08, 2008 7:40 pm ]
Post subject:  Re: How to orient third person lasers?

Sergeant Kelly wrote:
So this code gives the weapon a new class and sets the laser to use that specific class? It looks pretty sophisticated.


All that code does is give the AH104's attachment class a pointer to the weapon it represents. It then takes the aim and recoil values from the weapon and applies it to the laser. Your attachment code didn't work because it was expecting the weapon class to be a subclass of BallisticHandgun, which it apparently is not

I copied it word-for-word from the SARAttachment class. :D

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/