Torque Game Engine - Getting the players coordinates...

Started by
4 comments, last by Manoel Balbino 16 years, 1 month ago
Basically im trying to find out the players current coordinates and also split it up to individually assign it to variables, for example x coord to a variable, y coord to another variable and so on. i tried searching but all i could come up with is getword or something? not quite sure how to do it. More specifically is there anyway i can find the player position outside of a GameConnection method? ive tried but to no avail.. is there anyway to always assign the same id to the player everytime it respawns? for example when it dies? that way i could call getTransform with the same id each time? tried on the garagegames forums but so far nothing, this seemed like a good place to also ask :) cheers
Advertisement
I just did a quick test, pushed F11 to see my player's ID which ended up being 1811
then went
echo(1811.getTransform()); which prints his current location

and to get the individual parts it's like this
%x = getword(1811.getTransform(),0)
%y = getword(1811.getTransform(),1)
%z = getword(1811.getTransform(),2)
Quote:Original post by eedok
I just did a quick test, pushed F11 to see my player's ID which ended up being 1811
then went
echo(1811.getTransform()); which prints his current location

and to get the individual parts it's like this
%x = getword(1811.getTransform(),0)
%y = getword(1811.getTransform(),1)
%z = getword(1811.getTransform(),2)


yeah thats actually part of the problem because im doing it via script and when the player dies the id is not the same as it was when the game was first started, also i am checking the players position regularly.

Quote:Original post by PsychicFreak
Quote:Original post by eedok
I just did a quick test, pushed F11 to see my player's ID which ended up being 1811
then went
echo(1811.getTransform()); which prints his current location

and to get the individual parts it's like this
%x = getword(1811.getTransform(),0)
%y = getword(1811.getTransform(),1)
%z = getword(1811.getTransform(),2)


yeah thats actually part of the problem because im doing it via script and when the player dies the id is not the same as it was when the game was first started, also i am checking the players position regularly.


I haven't checked this, and my experience with Torque is limited, but can't you do something along the lines of "%serverconnection.getControlObject().getTransfrom()" ?
I know the server side connection object has a control object. I'm not sure about the client side connection thought.
STOP THE PLANET!! I WANT TO GET OFF!!
hmmm, is there a way to name the object the same thing everytime its created then? because i know that works to call getTransform as well...

apologies for all the questions, im using torque to create a game for my final year project, im using the players coordinates for a very simple AI and its the last thing i need to do before starting on the report :)

cheers for the help so far...
LocalClientConnection.getControlObject() will return the object currently under the client control, and LocalClientConnection.player stores the current player ID. Not that this applies to the machine that is hosting the game, on a multiplayer setting you'll need to deal with multiple clients.

This topic is closed to new replies.

Advertisement