// Update is called once per frame void Update() { if (IsInside()) { GetComponent <Collider2D>().enabled = true; } else { GetComponent <Collider2D>().enabled = false; } animator.SetBool("flying", IsInside()); float hAxis = getAxisH(); float vAxis = getAxisV(); if (IsInside()) { Vector2 movement = new Vector2(hAxis, vAxis); unitRigidbody.velocity = movement * speedMultiplier; } else { Vector2 aim = new Vector2(hAxis, vAxis); if (aim.magnitude > 0.1f) { lastAim = new Vector2(hAxis, vAxis); } otherWitch.GetComponent <PlayerController>().SetAim(lastAim); if (getFireButton() && myTime >= fireRate) { unit.PlayShoot(); animator.SetTrigger("attack"); myTime = 0.0f; GameObject newBullet = Instantiate(bullet, transform.position, transform.rotation); newBullet.GetComponent <PlayerBullet>().SetDirection(transform.position - unit.transform.position); newBullet.GetComponent <PlayerBullet>().SetColor(color); newBullet.GetComponent <Rigidbody2D>().velocity = transform.position - unit.transform.position; } myTime += Time.deltaTime; } if (getSwitchButton() && !readyToSwitch) { readyToSwitch = true; StartCoroutine(switchTimer()); } if (getUltButton() && !readyToAttack) { readyToAttack = true; StartCoroutine(AttackTimer()); } switchDownTime += Time.deltaTime; }