// Use this for initialization void Start() { mapSeq = new int[8]; mapSrc = new GameObject[8]; for (int i = 0; i < 8; i++) { mapSeq[i] = ball.GetComponent <Ball>().mapSeq[i]; } for (int i = 0; i < 8; i++) { string mapName = "rr" + mapSeq[i].ToString(); mapSrc[i] = (GameObject)Instantiate(Resources.Load(mapName)); } mapSrc[0].GetComponent <Transform>().localPosition = new Vector3(-30, 0, -30); mapSrc[1].GetComponent <Transform>().localPosition = new Vector3(-30, 0, 0); mapSrc[2].GetComponent <Transform>().localPosition = new Vector3(-30, 0, 30); mapSrc[3].GetComponent <Transform>().localPosition = new Vector3(0, 0, -30); mapSrc[4].GetComponent <Transform>().localPosition = new Vector3(0, 0, 30); mapSrc[5].GetComponent <Transform>().localPosition = new Vector3(30, 0, -30); mapSrc[6].GetComponent <Transform>().localPosition = new Vector3(30, 0, 0); mapSrc[7].GetComponent <Transform>().localPosition = new Vector3(30, 0, 30); }
private void Awake() { // Set up the reference. ball = GetComponent <Ball>(); rb = ball.GetComponent <Rigidbody>(); floorMask = LayerMask.GetMask("Floor"); // get the transform of the main camera if (Camera.main != null) { cam = Camera.main.transform; } else { Debug.LogWarning( "Warning: no main camera found. Ball needs a Camera tagged \"MainCamera\", for camera-relative controls."); // we use world-relative controls in this case, which may not be what the user wants, but hey, we warned them! } }