Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Number overflow

$
0
0
i have no clue what is wrong here..iv looked and the script looks ok but when i hit play i get Number overflow public class Grid : MonoBehaviour { public Vector2 gridworldsize; public float noderadice; public LayerMask unwalkable; Nodeclass[,] grid; float nodeDiamater; int gridSizeX, gridSizeY; void Start () { nodeDiamater = noderadice * 2; gridSizeX = Mathf.RoundToInt (gridworldsize.x / nodeDiamater); gridSizeY = Mathf.RoundToInt (gridworldsize.y / nodeDiamater); CreateGrid (); } void CreateGrid (){ grid = new Nodeclass[gridSizeX,gridSizeY]; Vector3 worldbottomleft = transform.position - Vector3.right * gridworldsize.x / 2 - Vector3.forward * gridworldsize.y / 2; for (int x = 0; x < gridSizeX; x++) { for (int y = 0; y < gridSizeY; y++) { Vector3 worldpoint = worldbottomleft + Vector3.right * (x * nodeDiamater + noderadice) + Vector3.forward * (y * nodeDiamater + noderadice); bool walkable = !(Physics.CheckSphere (worldpoint, noderadice)); grid [x, y] = new Nodeclass (walkable, worldpoint); print ("this is now working"); } } } void OnDrawGizmos(){ Gizmos.DrawWireCube(transform.position,new Vector3 (gridworldsize.x,1,gridworldsize.y)); if (grid != null) { foreach (Nodeclass n in grid) { Gizmos.color = (n.walkable) ? Color.white : Color.red; Gizmos.DrawCube (n.worldPosition, Vector3.one * (nodeDiamater - .1f)); } } } } what is wrong with it?

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>