Jump to content

Recommended Posts

Posted

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);

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Posted

 

//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
Posted

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

Posted

In this specific case I think DrawText() takes an int, but I get what you were trying to show. Just don't want to confuse him if he tries that and nothing happens because it truncates the value to an int, which it's doing right now for him anyway :)

  • Upvote 1

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.

×
×
  • Create New...