// Use this for initialization void Start() { Material loadedMaterial = null; if (GameObject.Find("Ball")) { loadedMaterial = GameObject.Find("Ball").GetComponent<Renderer>().sharedMaterial; Destroy(GameObject.Find("Ball")); } TextureSwapBall[] textureBalls = GameObject.FindObjectsOfType<TextureSwapBall>(); if (loadedMaterial) { foreach (TextureSwapBall thisBall in textureBalls) { if (thisBall.ballMaterial == loadedMaterial) { currentBall = thisBall; } } } else { currentBall = GameObject.FindObjectOfType<TextureSwapBall>(); } menuLoad = GameObject.Find("Scripts").GetComponent<LoadScenes>(); textureData = GameObject.Find("TextureSwapData").GetComponent<TextureSwapData>(); mainCamera.transform.position = new Vector3(currentBall.transform.position.x, currentBall.transform.position.y, mainCamera.transform.position.z); currentX = currentBall.transform.position.x; moveSpeed = .5f; timer = 0; moveCamera = false; }
public void MoveToRight() { if(currentBall.rightBall != null) { moveToX = currentBall.rightBall.transform.position.x; currentBall = currentBall.rightBall; moveCamera = true; } }