Throwing Weapons
by Neil Marshall · in Torque Game Engine · 08/23/2002 (4:05 pm) · 4 replies
I have decided to try to program a frisbee. I've copied the crossbow.cs file, renamed everything to Frisbee, added the maxInv, and exec'ed the script.
In the game go throught the editor and place a frisbee in the scene. When I walk over it, it picks it up and mounts it, but this is where the problems start.
I get "fps/server/scripts/inventory.cs (136): Unable to find object: '' attempting to call function 'getName'"
What am I missing? It's still part of the weapon class. It has a pickupName, I can't figure out what "name" I'm missing.
In the game go throught the editor and place a frisbee in the scene. When I walk over it, it picks it up and mounts it, but this is where the problems start.
I get "fps/server/scripts/inventory.cs (136): Unable to find object: '' attempting to call function 'getName'"
What am I missing? It's still part of the weapon class. It has a pickupName, I can't figure out what "name" I'm missing.
#2
I think It has something to do with the noammo stuff, but I'm not sure.
08/23/2002 (4:32 pm)
The other weapons work.I think It has something to do with the noammo stuff, but I'm not sure.
#3
08/23/2002 (5:05 pm)
make sure you have the "ammo = whateverammo;" in your image for your throwing weapon, or else it wont check for the ammo.
#4
How do I make it fire the weapon and then stop?
Now the second problem... why doesn't the weapon dissapear from the players hands when it's thrown? Is it because of the code above or am I doing something wrong in my onFire code?
08/23/2002 (5:42 pm)
Haha, I must have run into the funniest bug. I accidently set the weapon to throw itself constantly. So the player is standing there tossing frisbees on the ground and never stops. Technically he should only have one weapon and it should delete it when it's thrown. Maybe someone else can spot the problems.stateName[0] = "Activate"; stateTransitionOnTimeout[0] = "Ready"; stateTimeoutValue[0] = 0.6; stateSequence[0] = "Activate"; stateName[1] = "Ready"; stateTransitionOnNoAmmo[1] = "Fire"; stateTransitionOnTriggerDown[1] = "Fire"; stateName[2] = "Fire"; stateTransitionOnTimeout[2] = "Ready"; stateTimeoutValue[2] = 0.2; stateFire[2] = true; stateRecoil[2] = LightRecoil; stateAllowImageChange[2] = false; stateSequence[2] = "Fire"; stateScript[2] = "onFire";
How do I make it fire the weapon and then stop?
Now the second problem... why doesn't the weapon dissapear from the players hands when it's thrown? Is it because of the code above or am I doing something wrong in my onFire code?
function FrisbeeImage::onFire(%this, %obj, %slot)
{
%obj.decInventory(%this, 1);
%muzzleVector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%muzzleVelocity = VectorAdd(
VectorScale(%muzzleVector, %projectile.muzzleVelocity),
VectorScale(%objectVelocity, %projectile.velInheritFactor));
%fris = new item() {
dataBlock = Frisbee;
};
%pos = %obj.getMuzzlePoint(%slot);
%fris.setTransform( %pos );
%fris.applyImpulse(%pos, %muzzleVelocity);
MissionCleanup.add(%fris);
return %fris;
}
Trevor "PointDestruction"