Sign in to follow this  

Torque Game Engine - Getting the players coordinates...

This topic is 3559 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3559 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this