Game Development Community

Forward facing direction vector

by arda · in Torque Game Engine · 03/22/2005 (3:29 pm) · 3 replies

I'm making simple modifications to AI guard resource.
I want AI player not to fire immediately, I want AI player wait for a sec to focus in on the target
if AI player and Player are not facing each other.

To do that I need to know forward facing vector of AI player and player.
How can I find the forward facing vector of AI player and Player.


Thanks.

#1
03/22/2005 (3:38 pm)
GetForwardVector(); should work.
#2
03/22/2005 (4:04 pm)
Nope !

%tgt.dump()

- output is at the bottom of this page , and it does not have GetForwardVector();

I also tried

%tgtPos = %tgt.player.getTransform();

%lx = getword(%tgtPos, 0) + GetRandom(0, $AI_GUARD_AIMING_MAX_RADIUS) ;
%ly = getword(%tgtPos, 1) + GetRandom(0, $AI_GUARD_AIMING_MAX_RADIUS) ;
%lz = getword(%tgtPos, 2);

%rx = getword(%tgtPos, 3);
%ry = getword(%tgtPos, 4);
%rz = getword(%tgtPos, 5);
Echo("Rotation matrix" SPC %rx SPC %ry SPC %rz);

- Result is

Rotation matrix 0 0 1
Rotation matrix 0 0 1
Rotation matrix 0 0 1
Rotation matrix 0 0 1
Rotation matrix 0 0 1
Rotation matrix 0 0 1
Rotation matrix 0 0 1
Rotation matrix 0 0 1

- So It's just displaying object space local rotation transform.

Any other Idea?

Thanks, anyway

Dumping tgt-------------
Member Fields:
Tagged Fields:
armor = "Light"
Camera = "1445"
currentPhase = "3"
gender = "Male"
guid = "0"
isAdmin = "1"
isSuperAdmin = "1"
name = "\c013"
nameBase = "Murat"
Player = "1446"
race = "Human"
score = "0"
sendGuid = "0"
skin = "\c012"
Methods:
activateGhosting() -
add() -
bringToFront() -
chaseCam() -
checkMaxRate() -
clear() -
clearPaths() -
clientWantsGhostAlwaysRetry() -
connect() -
connectLocal() -
createPlayer() -
delete() -
dump() -
endMission() -
getAddress() -
getClassName() -
getControlCameraFov() -
getControlObject() -
getCount() -
getGhostID() -
getGhostsActive() -
getGroup() -
getId() -
getName() -
getObject() -
getPacketLoss() -
getPing() -
getServerConnection() -
getType() -
incScore() -
initialControlSet() -
isAIControlled() -
isDemoPlaying() -
isDemoRecording() -
isMember() -
listObjects() -
loadMission() -
onClientEnterGame() -
onClientLeaveGame() -
onConnect() -
onConnectionAccepted() -
onConnectionDropped() -
onConnectionError() -
onConnectionTimedOut() -
onConnectRequest() -
onConnectRequestRejected() -
onConnectRequestTimedOut() -
onDataBlocksDone() -
onDeath() -
onDrop() -
onEnterMissionArea() -
onGhostAlwaysFailed() -
onGhostAlwaysObjectsReceived() -
onLeaveMissionArea() -
play2D() -
play3D() -
playDemo() -
pushToBack() -
remove() -
resetGhosting() -
resolveGhostID() -
resolveObjectFromGhostIndex() -
save() -
schedule() -
setBlackOut() -
setConnectArgs() -
setControlCameraFov() -
setControlObject() -
setJoinPassword() -
setLagIcon() -
setMissionCRC() -
setName() -
setPlayerName() -
setSimulatedNetParams() -
spamMessageTimeout() -
spamReset() -
spawnPlayer() -
startMission() -
startRecording() -
stopRecording() -
syncClock() -
transmitDataBlocks() -
transmitPaths() -
#3
03/22/2005 (5:06 pm)
I found answer, but still have questions in mind.

Echo("Player Eye Vector = " SPC %tgt.player.getEyeVector());
Echo("AI Player Eye Vector = " SPC %obj.getEyeVector());

What is the difference between %tgt.player and %obj ?
Is %tgt data block? If so how I get the reference to object refering to that datablock?
And How can I understand if a variable is datablock or object?

I'm learing a lot from GG community, they all are nice people,
The best part is to be able to find someone to get help :)

Cheers.

----------------------- Actual code snippet begin ----
%tgtid = %this.GetClosestHumanInSightandRange(%obj);
//If %tgtid>0 then there is a valid target
if(%tgtid >=0)
{
//Get the current player object from the client value set in %tgtid
%tgt = ClientGroup.getobject(%tgtid);

// If AI player is chasing, (AI player sees player but, player does not see AI player)
// try to decrease fire window radius instead of firing
// If fire windows is small enough fire
Echo("Player Eye Vector = " SPC %tgt.player.getEyeVector());
Echo("AI Player Eye Vector = " SPC %obj.getEyeVector());

----------------------- Actual code snippet end ----