// Update is called once per frame void Update() { if (!finished) { float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); Vector3 move = new Vector3(moveHorizontal, moveVertical, 0.0f); ball.AddForce(move * speed); } if (transform.position.y > -0.35) { ballPos.transform.position = new Vector3(transform.position.x, -0.35f, transform.position.z); } if ((transform.position.x > -0.28) && (transform.position.y < -1.95)) { finished = true; speed = 0f; ballPos.transform.position = new Vector3(-0.28f, -1.97f, transform.position.z); finishedLight.SetActive(true); } if (finished && !alreadyRun) { correct.Play(); alreadyRun = true; codeScript.AddToCode(); } }
// Update is called once per frame void Update() { if (!finished) { float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); Vector3 move = new Vector3(moveHorizontal, moveVertical, 0.0f); ball.AddForce(move * speed); } if ((transform.position.x < -2.20) && (transform.position.y < -2.18)) //blue endzone { if (matNum == 0) { finished = true; speed = 0f; ballPos.transform.position = new Vector3(-2.22f, -2.19f, transform.position.z); //finishedLight.SetActive (true); } else { ballPos.transform.position = new Vector3(-2.17f, -2.18f, transform.position.z); } } if ((transform.position.x > -0.17) && (transform.position.y > -0.126)) //red end zone { if (matNum == 1) { finished = true; speed = 0f; ballPos.transform.position = new Vector3(-0.15f, -0.1f, transform.position.z); //finishedLight.SetActive (true); } else { ballPos.transform.position = new Vector3(-0.15f, -0.14f, transform.position.z); } } if ((transform.position.x < -2.19) && (transform.position.y > -0.15)) //green end zone { if (matNum == 2) { finished = true; speed = 0f; ballPos.transform.position = new Vector3(-2.19f, -0.15f, transform.position.z); //finishedLight.SetActive (true); } else { ballPos.transform.position = new Vector3(-2.17f, -0.15f, transform.position.z); } } if ((transform.position.x > -0.16) && (transform.position.y < -2.189)) //yellow end zone { if (matNum == 3) { finished = true; speed = 0f; ballPos.transform.position = new Vector3(-0.14f, -2.19f, transform.position.z); //finishedLight.SetActive (true); } else { ballPos.transform.position = new Vector3(-0.14f, -2.17f, transform.position.z); } } if (finished && !alreadyRun) { correct.Play(); alreadyRun = true; codeScript.AddToCode(); } }