I was working on a pirate ship and I needed the cannons to shoot. Each player controls their own cannon. But I cannot figure out how to make it so the player in mount1 fires it instead of mount0
function Shipvehicle::onTrigger(%this, %obj, %triggerNum, %val)
{
if(%triggerNum == 2 && %val && !iseventpending(%obj.rocketreload)){ //If they've pressed space bar and reloading isn't happening
%obj.client = %obj.getcontrollingclient(); //Find who's controlling the plane
%pos = %obj.getposition(); // Position stuff lol
%client = %obj.client; // More stuff
%pos = vectoradd(%pos,"-3 0 2"); // A little bit below the plane
%pos = vectoradd(%pos,%obj.getforwardvector()); // Make sure stuff's in front of the plane
%vel = "0 -90 0"; //Launch the bomb downwards so it hits something
%planevz = getword(%obj.getvelocity(),2);
if(%planevz < 0){
%vel = VectorAdd(%vel,"0 0 " @ %planevz);
}
%p = new Projectile() //Make the rocket
{
dataBlock = GunProjectile; //Could be any projectile, but it blows up on the vehicle if it's still in contact after half a second
initialVelocity = %vel;
initialPosition = %pos;
client = %obj.client;
sourceObject = %obj.client.player;
sourceClient = %obj.client;
};
MissionCleanup.add(%p); //Make sure stuff happens
%obj.rocketreload = schedule(500,0,""); //Reloads the rocket in one second
}
}
function untrigger(%obj, %trigger) //Makes the gun untrigger
{
%obj.setimagetrigger(%trigger,0);
}
Also, it fires the same direction no matter which way you face, how would I change that?