Author Topic: Raycasting Explosion Failure  (Read 834 times)

So yeah, I'm having trouble making it raycast the explosion only when I fire.  When I equip the weapon it spams the explosion when it's supposed to spawn a laser.

Here's the raycasting function:
Code: [Select]
function LeviathanImage::Search(%this, %obj, %slot)
{
%start = %obj.getMuzzlePoint(%slot);
%end = vectorAdd(%start, vectorScale(%obj.getMuzzleVector(%slot), 500));
%typemasks = $Typemasks::PlayerObjectType | $Typemasks::FxBrickObjectType | $Typemasks::TerrainObjectType | $Typemasks::InteriorObjectType | $TypeMasks::StaticObjectType | $TypeMasks::VehicleObjectType;
%ray = containerRaycast(%start, %end, %typemasks, %obj);
if(isObject(%hit = firstWord(%ray)))
{
%pos = posFromRaycast(%ray);
%apos = vectorAdd(%pos, vectorScale(normalFromRaycast(%ray), 0.05));
%prj = new Projectile()
{
datablock = LeviathanEmitterA;
initialPosition = %apos;
initialVelocity = "0 0 0";
scale = %obj.getScale();
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
}
}

function LeviathanImage::onFire(%this, %obj, %slot)
{
if(%obj.lastShot[%this] + %this.minShotTime > getSimTime())
{
return;
}
%obj.lastShot[%this] = getSimTime();
%start = %obj.getMuzzlePoint(%slot);
%end = vectorAdd(%start, vectorScale(%obj.getMuzzleVector(%slot), 500));
%typemasks = $Typemasks::PlayerObjectType | $Typemasks::FxBrickObjectType | $Typemasks::TerrainObjectType | $Typemasks::InteriorObjectType | $TypeMasks::StaticObjectType | $TypeMasks::VehicleObjectType;
%ray = containerRaycast(%start, %end, %typemasks, %obj);
if(isObject(%hit = firstWord(%ray)))
{
%pos = posFromRaycast(%ray);
%apos = vectorAdd(%pos, vectorScale(normalFromRaycast(%ray), 0.05));
%prj = new Projectile()
{
datablock = LeviathanEmitterA;
initialPosition = %apos;
initialVelocity = vectorScale(%obj.getMuzzleVector(%slot), 200);
scale = %obj.getScale();
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
Leviathanbullet = true;
};
}
}

Also here's pic of the weapon:

And, the "Tuevon Sionto" is only my LAN name, IGN Tuevon.

Is LeviathanEmitterA a projectile? You're spawning a projectile using its datablock, which is going to cause problems if it's an emitter.

No, the LeviathanEmitterA is the laser pin-point.

I could really use some help on this, as I'd rather not unintentionally create he cheapest weapon in all of Blockland.
Could the line:
Code: [Select]
Leviathanbullet = true;have anything to do with it since it is in the Laser datablock's area?
« Last Edit: September 13, 2011, 10:25:47 PM by SWAT One »