Game Development Community

Location on Map

by Kamal Syed · in Torque Game Engine · 02/29/2004 (8:58 am) · 12 replies

Is there a way to get the coordinate of your buggy or player on the map inside scripting? I know it can be done in C++ code, but is there a way to tap into this feature through scripting?

Thanks in advance.

#1
02/29/2004 (9:16 am)
GetPosition() ?
#2
02/29/2004 (9:43 am)
Can you please elaborate a bit more?
#3
02/29/2004 (9:54 am)
function flightStatus()
{
echo("Welcome to Torque airlines. The aircraft is currently flying above " @ localclientconnection.player.getPosition() @ ", and we are currently cruising at a steady speed of " @ VectorLen(localclientconnection.player.getVelocity()) @ " torks, With a heading of " @ localclientconnection.player.getForwardVector());
}
#4
02/29/2004 (11:55 am)
Now that's more like it :). Thanks James.
#5
02/29/2004 (1:18 pm)
Hm...on second thought, getForwardVector, getVelocity and getPosition seem to be undeclared. Did you try out that function James?
#6
02/29/2004 (2:24 pm)
Those should all be set on the Player and Vehicle classes. What type of object are you calling them on? What's the error it gives you when you try?
#7
02/29/2004 (4:58 pm)
Sorry, but I was looking for this in the docs, just to check it out and I can't seem to find it in the Player or Vehicle Class Reference. I'm looking through a Doxygen build of the latest HEAD release.

Could you tell me where to find GetPosition() in the docs?

Thanks
#8
02/29/2004 (5:07 pm)
Keep in mind that localclientconnection will not work in a network (MP) game.
#9
03/01/2004 (9:01 am)
So, I guess it's not in the docs then? If it's declared then shouldn't Doxygen generate it?
#10
03/01/2004 (9:22 am)
The chain looks a bit like this
SceenObject->GameBase->ShapeBase->Player

GetPosition is part of SceenObject

ConsoleMethod( SceneObject, getPosition, const char*, 2, 2, "Get position of object.")
{
   char *returnBuffer = Con::getReturnBuffer(256);
   const MatrixF& mat = object->getTransform();
   Point3F pos;
   mat.getColumn(3,&pos);
   dSprintf(returnBuffer,256,"%g %g %g",pos.x,pos.y,pos.z);
   return returnBuffer;
}

-Ron
#11
03/01/2004 (12:04 pm)
Doxygen won't generate it because it's scripting, not C++. Doxygen only documents the C++ side of things.
#12
03/01/2004 (1:24 pm)
Many thanks for the response, it really helps to clear things up.