This is the preview of how this works.
you can download it here www.geocities.com/herrudarmadi/3darrow.zip
place it on data/shapes/direction/arrow.dts
first add this to your server/game.cs
$aimTarget = 0;
function GameConnection::AimTarget( %this )
{
if($aimTarget)
{
%player = %this.player;
%target = $aimTarget;
%playerTrans = (%player.getTransform());
%xPlayer = getWord(%playerTrans, 0);
%yPlayer = getWord(%playerTrans, 1);
%zRot = getWord(%playerTrans, 5);
%playerRot = getWord(%playerTrans, 6);
%targetPosition = (%target.getPosition());
%xTarget = getWord(%targetPosition, 0);
%yTarget = getWord(%targetPosition, 1);
%xDiff = %xTarget - %xPlayer;
%yDiff = %yTarget - %yPlayer;
// dont have to change it to degrees
// torque engine automatically change it to degrees
%rotToTarget = mAtan(%xDiff, %yDiff);
if(%zRot < 0)
%playerRot = (2 * 22/7) - %playerRot;
// multiply by -1 because the rotation in 3dspace is
// oppositing the guiobjectview rotation
%rotation = -1 * (%rotToTarget - %playerRot);
commandToClient(%this, 'SetDirection', %rotation);
}
%this.schedule(100, AimTarget);
}
on the client/ui/playgui.gui add
new GuiObjectView(direction) {
canSaveDynamicFields = "0";
Profile = "GuiDefaultProfile";
HorizSizing = "center";
VertSizing = "bottom";
position = "244 94";
Extent = "149 149";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
applyFilterToChildren = "1";
cameraZRot = "0";
forceFOV = "0";
lightDirection = "-0.57735 -0.57735 -0.57735";
lightColor = "0.6 0.58 0.5 1";
ambientColor = "0.3 0.3 0.3 1";
emapAmount = "1";
};
and on the client/playgui.cs add
function PlayGui::onWake(%this)
{
// Turn off any shell sounds...
// alxStop( ... );
$enableDirectInput = "1";
activateDirectInput();
direction.setObject("gb","mod/data/shapes/direction/arrow.dts","","");
// Activate the game's action map
moveMap.push();
}
function clientCmdSetDirection(%rotation)
{
direction.setRotation(0, %rotation );
}
how to use it ?
just set the $aimTarget to any object id in your mission.
then call the gameConnection method aimTarget().
that's it, hope this resource usefull. cheers!