Guest User

Untitled

a guest
Apr 25th, 2024
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.38 KB | None | 0 0
  1. private GridNode NodeFromWorldPoint(Vector3 worldPosition)
  2. {
  3.     int evenX = Mathf.FloorToInt(worldPosition.x) % 2 == 0 ? Mathf.FloorToInt(worldPosition.x) : Mathf.FloorToInt(worldPosition.x) - 1;
  4.     int evenZ = Mathf.FloorToInt(worldPosition.z) % 2 == 0 ? Mathf.FloorToInt(worldPosition.z) : Mathf.FloorToInt(worldPosition.z) - 1;
  5.  
  6.     return grid[new Vector2Int(evenX, evenZ)];
  7. }
Add Comment
Please, Sign In to add comment