public void SetWorldLimits() { float dx = width * (chunkSize.x / 2) * 1.75f; float dy = -(chunkSize.y) * (heigth) * 1.75f; GameObject DeathLimits = new GameObject("DeathLimits"); DeathLimits.transform.parent = transform; DeathLimit.CreateDeathLimit(DeathLimits, Vector3.down, new Vector3(-dx, dy / 2 + (chunkSize.y / 2), 0), new Vector3(150, heigth + 1, 0)); DeathLimit.CreateDeathLimit(DeathLimits, Vector3.up, new Vector3(dx, dy / 2 + (chunkSize.y / 2), 0), new Vector3(150, heigth + 1, 0)); DeathLimit.CreateDeathLimit(DeathLimits, Vector3.left, new Vector3(0, chunkSize.y, 0), new Vector3(width, 150, 0)); DeathLimit.CreateDeathLimit(DeathLimits, Vector3.right, new Vector3(0, dy, 0), new Vector3(width, 150, 0)); }
public static DeathLimit CreateDeathLimit(GameObject parent, Vector3 axis, Vector3 pos, Vector3 size) { GameObject limit = new GameObject("DeathLimith"); limit.transform.parent = parent.transform; limit.SetActive(false); DeathLimit myC = limit.AddComponent <DeathLimit>(); myC.dir = axis; myC.pos = pos; myC.size = size; limit.SetActive(true); return(myC); }