// Update is called once per frame void Update() { //each frame, set my position to if (timer >= 0.01667f) { if (newPositions.Count > 0) { transform.position = newPositions[0]; newPositions.RemoveAt(0); } timer += TimeStopController.deltaTime() - 0.01667f; } else { timer += TimeStopController.deltaTime(); } if (stuck) { print("hello?"); rb.velocity = Vector3.zero; useGravity = true; } //print(rb.velocity + "/" + (Physics.gravity * TimeStopController.getTimeScale())); if (useGravity) { print("hello"); transform.GetChild(0).GetComponent <Animator>().SetBool("bombOpen", true); rb.AddForce(Physics.gravity * TimeStopController.getTimeScale()); } transform.GetChild(0).GetComponent <Animator>().speed = 1 * TimeStopController.timeScale; }
private void Update() { if (currentLifeTime <= 0) { Destroy(this.gameObject); } else { currentLifeTime -= Time.deltaTime * TimeStopController.timeScale; } rb.velocity = topVal * TimeStopController.getTimeScale(); //Stop mid air }
// Update is called once per frame void Update() { //GetComponentInChildren<Animator>().speed = TimeStopController.timeScale; transform.GetChild(1).GetComponent <Animator>().speed = 1 * TimeStopController.timeScale; transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().speed = TimeStopController.timeScale; int lerpSpeed = 10; float targetScale = 1; if (Input.GetKeyUp(KeyCode.Mouse0) && !GC.pauseGameObj.activeSelf && !GC.gameOverObj.activeSelf) { print("Mouse0: Trans-Shoot"); gunPrefab.GetComponent <GunController>().shootTrans(); targetScale = 0.5f; transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().Play("Gun_Fire"); StartCoroutine(wait(1)); } else if (Input.GetKeyUp(KeyCode.Mouse1) && !GC.pauseGameObj.activeSelf && !GC.gameOverObj.activeSelf) { print("Mouse0: Bomb-Shoot"); if (GameController.instance.haveBombs()) { if (gunPrefab.GetComponent <GunController>().throwBomb(transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>())) { //same as above targetScale = 0.5f; GameController.instance.spendBombs(1); transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().SetBool("isPredictingBomb", false); } } } if (!transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().GetBool("isPredictingBomb")) { gunPrefab.SetActive(true); BombPrefabHand.SetActive(false); } if (Input.GetKey(KeyCode.Mouse1)) { gunPrefab.GetComponent <GunController>().bombPrediction(); transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().SetBool("isPredictingBomb", true); gunPrefab.SetActive(false); BombPrefabHand.SetActive(true); } else { gunPrefab.GetComponent <GunController>().destroyDots(); } if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D)) { targetScale = 1; } else { targetScale = 0; lerpSpeed = 4; } if (Input.GetKey(KeyCode.LeftShift)) { transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().SetBool("isRunning", true); } else { transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().SetBool("isRunning", false); } TSC.setTimeScale(Mathf.Lerp(TimeStopController.getTimeScale(), targetScale, Time.deltaTime * lerpSpeed)); }