Vehiclular Weaponry
by Daniel Neilsen · in Torque Game Engine · 03/07/2002 (3:03 pm) · 6 replies
Hey guys,
Has anyone, as yet, managed to get get weapons to work on vehicles? I added a weapon to the default wheeled vehicle and that worked and the mouse trigger is working but nothing fires...
in WheeledVehicleData::onAdd
The trigger and state are echoed correctly so I know that this is working and you can see the weaponimage mounted above the vehicle so this is obviously correct..
No projectiles though :/
Any ideas guys?
Has anyone, as yet, managed to get get weapons to work on vehicles? I added a weapon to the default wheeled vehicle and that worked and the mouse trigger is working but nothing fires...
in WheeledVehicleData::onAdd
//vehicleweapon is the waepon image previosuly declared
%obj.mountimage(VehicleWeapon, 0, true);
function WheeledVehicleData::onTrigger(%this, %obj, %trigger, %state)
{
echo("trigger = ",%trigger," state = ",%state);
if(%trigger == 0)
{
switch(%state)
{
case 0:
%obj.setImageFiring(0, false);
case 1:
%obj.setImageFiring(1, true);
}
}
}The trigger and state are echoed correctly so I know that this is working and you can see the weaponimage mounted above the vehicle so this is obviously correct..
No projectiles though :/
Any ideas guys?
About the author
#3
I would assume that there is no valid mounted image
you say you can see it tho..
but when you ask it
%obj.getImageState(node);
it returns a 0?
.. it should return a string ..
ive never suffered from this..
where are you mounting the image?
onAdd?
03/07/2002 (3:57 pm)
if you cannot get a state from the weapon ..I would assume that there is no valid mounted image
you say you can see it tho..
but when you ask it
%obj.getImageState(node);
it returns a 0?
.. it should return a string ..
ive never suffered from this..
where are you mounting the image?
onAdd?
#4
I am mounting it in onadd and it moves with the vehicle fine.
I can do a %obj.getMountedImage(0); and it returns the object of the weaponimage fine.
03/07/2002 (6:27 pm)
yeahI am mounting it in onadd and it moves with the vehicle fine.
I can do a %obj.getMountedImage(0); and it returns the object of the weaponimage fine.
#5
You need to change some script. Do not remember from memory, but somewhere in weapon.cs, there are some tests regarding client classname and if it's Player, then it will fire, otherwise no.
BTW, you should also run the use command to attach the weapon to the vehicles.
03/08/2002 (12:17 am)
I get it worked with vehicles.You need to change some script. Do not remember from memory, but somewhere in weapon.cs, there are some tests regarding client classname and if it's Player, then it will fire, otherwise no.
BTW, you should also run the use command to attach the weapon to the vehicles.
#6
03/08/2002 (12:59 pm)
Here is how I did it. This worksfunction WheeledVehicleData::onAdd(%this,%obj)
{
// Setup the car with some defaults tires & springs
for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--)
{
%obj.setWheelTire(%i,DefaultCarTire);
%obj.setWheelSpring(%i,DefaultCarSpring);
}
%data = %obj.getDataBlock();
%obj.setEnergyLevel(%data.maxEnergy);
//Add Vehicle Weapon
%obj.mountImage(VehicleWeapon, 0, true);
}
function WheeledVehicleData::onTrigger(%this, %obj, %trigger, %state)
{
if(%trigger == 0)
{
switch (%state)
{
case 0:
%obj.fireWeapon = false;
%obj.setImageTrigger(0, false);
case 1:
%obj.fireWeapon = true;
%obj.setImageTrigger(0, true);
}
}
}
Torque Owner Badguy
but I suggest you find out what state you image is in when you fire so ..
in your on trigger do something like this
messageAll('ImageData', 'Image State : %1', %obj.getImageState(0));
.. or an echo if you prefer