Got a problem with my airfield. Basically its a forcefield but instead of being vertical its horizontal and the centre of the platform is the centre of the emitter(but 8m above it).
The problem I am having is the location of the forcefield in comparison with the emitter is different depending on wether I look north, south, east or west. This is the code for that;
function SmallForceFieldDeployableImage::onDeploy(%item, %plyr, %slot)
{
$team = %plyr.client.team;
$owner = %plyr.client;
%xform = %item.deployed.getDeployTransform(%item.surfacePt, %item.surfaceNrm);
%rot = %item.rotation;
%fBase = 3.00; // this constant is 1/2 forcefield width on the x-coordinate (i.e. %fBase = 4.0, forcefield width = 8.0)
%dis = 1.22; // this constant is distance from deployed to forcefield
%deplTrf = %item.deployed.getDeployTransform(%item.surfacePt, %item.surfaceNrm);
%plyrPos = (getWord(%deplTrf, 0)) @ " " @ (getWord(%deplTrf, 1)) @ " " @ (getWord(%deplTrf, 2)); // X(east), Y, Z -sb
$deplRot = %plyr.rotation;
if(getWord(%plyr.rotation,2) == -1)
%angle = 3.1415 / (180.0 / (360.0 - (getWord(%plyr.rotation,3))));
else
%angle = 3.1415 / (180.0 / getWord(%plyr.rotation,3));
%alpha = %dis / (180 / (3.1415 /mTan(%fBase))); // [(%dis) is deployed to forcefield distance] ; [(%fBase) is length of forcefield x-axis]
%theta = 180.0 - (90.0 + %alpha); // [(%theta) is angle to forcefield origin (x,y) coordinates from players view angle]
%rTheta = 3.1415 / (180.0 / %theta); // [convert (%theta) to radians]
%vecA = %fBase / mCos(%alpha); // [vector length from deployed to forcefield origin (x,y) coordinates]
%xAdd = -6.000;
%yAdd = -6.000;
%zAdd = 1.000;
%vSum = (%xAdd @ " " @ %yAdd @ " " @ %zAdd);
$deplPos = VectorAdd(%plyrPos, %vSum);
%obj.shield = Parent::onDeploy(%item, %plyr, %slot);
return %obj.shield;
}
This is the standard forcefield orientation code I have which aligns it in the middle of the emitter when vertical;
function SmallForceFieldDeployableImage::onDeploy(%item, %plyr, %slot)
{
$team = %plyr.client.team;
$owner = %plyr.client;
%xform = %item.deployed.getDeployTransform(%item.surfacePt, %item.surfaceNrm);
%rot = %item.rotation;
%fBase = 3.00; // this constant is 1/2 forcefield width on the x-coordinate (i.e. %fBase = 4.0, forcefield width = 8.0)
%dis = 1.22; // this constant is distance from deployed to forcefield
%deplTrf = %item.deployed.getDeployTransform(%item.surfacePt, %item.surfaceNrm);
%plyrPos = (getWord(%deplTrf, 0)) @ " " @ (getWord(%deplTrf, 1)) @ " " @ (getWord(%deplTrf, 2)); // X(east), Y, Z -sb
$deplRot = %plyr.rotation;
if(getWord(%plyr.rotation,2) == -1)
%angle = 3.1415 / (180.0 / (360.0 - (getWord(%plyr.rotation,3))));
else
%angle = 3.1415 / (180.0 / getWord(%plyr.rotation,3));
%alpha = %dis / (180 / (3.1415 /mTan(%fBase))); // [(%dis) is deployed to forcefield distance] ; [(%fBase) is length of forcefield x-axis]
%theta = 180.0 - (90.0 + %alpha); // [(%theta) is angle to forcefield origin (x,y) coordinates from players view angle]
%rTheta = 3.1415 / (180.0 / %theta); // [convert (%theta) to radians]
%vecA = %fBase / mCos(%alpha); // [vector length from deployed to forcefield origin (x,y) coordinates]
%xAdd = %vecA * mSin(%angle - %rTheta);
%yAdd = (%vecA * mCos(%angle - %rTheta))-0.100;
%zAdd = 1.000;
%vSum = (%xAdd @ " " @ %yAdd @ " " @ %zAdd);
$deplPos = VectorAdd(%plyrPos, %vSum);
%obj.shield = Parent::onDeploy(%item, %plyr, %slot);
return %obj.shield;
}
Does anyone know the code so I can orientate the forcefield platform centred over the emitter whichever direction I look? If so could you also explain it.