| Blockland Forums > Modification Help |
| Raycasting Explosion Failure |
| (1/1) |
| SWAT One:
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: ---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; }; } } --- End code --- Also here's pic of the weapon: |
| SWAT One:
And, the "Tuevon Sionto" is only my LAN name, IGN Tuevon. |
| Amade:
Is LeviathanEmitterA a projectile? You're spawning a projectile using its datablock, which is going to cause problems if it's an emitter. |
| SWAT One:
No, the LeviathanEmitterA is the laser pin-point. |
| SWAT One:
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: ---Leviathanbullet = true; --- End code --- have anything to do with it since it is in the Laser datablock's area? |
| Navigation |
| Message Index |