public IEnumerator UseDash() { float dashTime = .25f; float startVelX = rb.velocity.x; Vector3 oldGravity = Physics.gravity; Physics.gravity = Vector3.zero; rb.velocity = Vector3.zero; fc.SetDashing(true); if (rb.isKinematic) { rb.isKinematic = false; } while (fc.GetDashing()) { rb.AddForce(new Vector3(500f, 0, 0)); yield return(new WaitForSeconds(dashTime)); rb.velocity = new Vector3(startVelX, 0, 0); fc.SetDashing(false); } Physics.gravity = oldGravity; yield return(null); }
// Update is called once per frame void Update() { if (fc.GetDashing()) { mainCamera.transform.position = new Vector3(playerCharacter.transform.position.x + 3, 0f, -10f); } else { mainCamera.transform.position = new Vector3(playerCharacter.transform.position.x + 3, 0f, -10f); } }
public void UseFlap() { if (rb.isKinematic) { rb.isKinematic = false; } if (fc.GetDashing() == false) { rb.velocity = new Vector3(fc.startVelX, 5f, 0f); } }