Ejemplo n.º 1
0
    private void HandleShooting()
    {
        if (timeBtwLastShot >= fireRate)
        {
            canShoot = true;
        }

        if (Input.GetMouseButton(0) && canShoot && !isShielding)
        {
            Vector3 spreadOffset = new Vector3(Random.Range(-1, 1), Random.Range(-1, 1), 0);
            Bullet.Create(GetPosition(), GameAssets.ToMouseDirection(GetPosition() + spreadOffset / 2, Input.mousePosition));
            timeBtwLastShot = 0;
            canShoot        = false;
        }
        timeBtwLastShot += Time.deltaTime;
    }
Ejemplo n.º 2
0
 private void HandleRotation()
 {
     mouse = GameAssets.ToMouseDirection(transform.position, Input.mousePosition);
     angle = Mathf.Atan2(mouse.y, mouse.x) * Mathf.Rad2Deg * Time.timeScale;
     transform.rotation = Quaternion.AngleAxis(angle - 180, Vector3.forward);
 }