- Home /
Mini Map that displays Players X,Y,Z coordinates
Hello Everyone! I have made a minimap using a second camera following my player as the target. (javascript) I would like to be able to display above or near the minimap on screen the players x,y,z coordinates as it moves around in world. I'm teaching young students about x,y and z spatial movement. Any advice would be greatly appreciated. Thank you! K.
Answer by DaveA · Jan 19, 2011 at 03:52 PM
Use a GUITExt or GUI.Label (see script reference for examples)
eg
function OnGUI () {
GUI.Label (Rect (10, 10, 100, 20), player.transform.position.ToString());
}
But I'm wondering how I would Script that to show the x,y,z player coordinates.
Depends on how accurate you want the coords to display. I like ToString(). Edited answer to reflect that.
Thank you Dave! Really appreciate the help. Have learned so much on this forum.
Answer by hike1 · Dec 18, 2012 at 12:15 AM
function OnGUI () { GUI.Label (Rect (10, 10, 100, 20), player.transform.position.ToString()); }
I took these lines and named it screen_coords.cs (or is it js?) Assets/Scripts/GUI/screen_coords.cs(1,10): error CS0116: A namespace can only contain types and namespace declarations
Eh, I get this error, and if it ever does work, do I just drag it onto the camera?
It's js code. Not cs code. And you would need to add a variable for the player.