CreativeOcclusion Posted October 14, 2012 Posted October 14, 2012 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); Quote
Roland Posted October 14, 2012 Posted October 14, 2012 DrawText (0,currentLine*12,"FPS() = %f",FPS()); currentLine++; DrawText (150,1,"X= %f ",playerpos.X); DrawText (275,1,"Y= %f ",playerpos.Y); DrawText (400,1,"Z= %f ",playerpos.Z); 2 Quote Roland Strålberg Website: https://rstralberg.com
Afke Posted October 14, 2012 Posted October 14, 2012 //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. 1 Quote
CreativeOcclusion Posted October 15, 2012 Author Posted October 15, 2012 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 Quote
Afke Posted October 15, 2012 Posted October 15, 2012 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 Quote
Dozz Posted October 15, 2012 Posted October 15, 2012 and if you want the text displaying to say 3 decimal places type %f4.3 1 Quote
Rick Posted October 15, 2012 Posted October 15, 2012 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 1 Quote
CreativeOcclusion Posted October 15, 2012 Author Posted October 15, 2012 thanks rick, i will look into that...but everything is working good right now so i might just leave it like it is....and thanks dozz, i did not know that.... Quote
Dozz Posted October 16, 2012 Posted October 16, 2012 %i is for integer, he has %f which is a float & he already said it displays to 6 places. I don't think it confused Quote
Rick Posted October 16, 2012 Posted October 16, 2012 Oh nvm, was mixed up on what param he was using that value for. Quote
Recommended Posts
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.