How do you convert a Vector3 position to the map x,y coordinates and place a marker on the map ?
Converting position to map coordinates
Discussion in 'Rust Development' started by Lamego, Dec 2, 2017.
-
Wulf Community Admin
You can get the x, y, z from the Vector3. Day if your Vector3 was named pos, then you can use pos.x to get the x part of the position.
-
Use position.x and position.y and just spawn a map marker prefab. You can just pass the position anyway though.
-
[DOUBLEPOST=1512233367][/DOUBLEPOST] -
I was able to figure out the coordinates translation by looking into the "teleport to coordinates" mod code:
var worldSize = (ConVar.Server.worldsize);
float offset =worldSize/2;
var gridWidth = (0.0066666666666667f*worldSize);
float step =worldSize/gridWidth;
int letter = ((int) 'A') + ((int)(offset-eventPos.z) / (int)step);
string c;
if(letter> ((int) 'Z'))
c="AA";
else
c= ((char)letter).ToString();