Jump to content

text player position


CreativeOcclusion
 Share

Recommended Posts

i am trying to text the players x y and z at the top of the screen...this code works sort of...i was just wondering if someone has a better snippit of code i can study...this code prints about 6 digits past the decimal and it seems to be inaccurate comparing it to the position of other models in the level...i just need accurate position of the controller called "player" in this code....thanks for your help...

 

 

 

 

//CODE TO GET PLAYER POSITION

 

 

 

TVec3 px=Vec3(playerpos.X);

 

TVec3 py=Vec3(playerpos.Y);

 

TVec3 pz=Vec3(playerpos.Z);

 

 

 

 

//print x,y,z of the player

 

DrawText (0,currentLine*12,"FPS() = %f",FPS()); currentLine++;

DrawText (150,1,"X= %f ",px);

DrawText (275,1,"Y= %f ",py);

DrawText (400,1,"Z= %f ",pz);

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

 

//CODE TO GET PLAYER POSITION

 

TVec3 px=Vec3(playerpos.X);

TVec3 py=Vec3(playerpos.Y);

TVec3 pz=Vec3(playerpos.Z);

 

//print x,y,z of the player

 

DrawText (0,currentLine*12,"FPS() = %f",FPS()); currentLine++;

DrawText (150,1,"X= %f ",px);

DrawText (275,1,"Y= %f ",py);

DrawText (400,1,"Z= %f ",pz);

 

Roland gave you the best solution. In this case use his code.

 

 

Vec3 has 3 Float values : x,y z

 

So it should be:

 

Float px= playerpos.X;
DrawText (150,1,"X= %f ",px);

 

But you don't need new variable in this case .Make new var only if you have to do same more calculation with it, and you don't want to change original variable.

  • Upvote 1
Link to comment
Share on other sites

Thanks Roland, this works perfect...and thanks afke...I am just learning leadwerks and am still learning c++...I really appreciate the help...I should have noticed that i was making a new variable for the same numbers...thanks

 

No problem man . We are here to help , just ask :)

 

Cheers

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...