void Shoot() { Vector3 currentSpawnPoint = Vector3.zero; gunn.BulletPrefab = currentWeapon.weaponData.bulletPrefab; gunn.ShootDelay = currentWeapon.weaponData.fireRate; for (int i = 0; i < spawnPoints.Length; i++) { if (spawnPoints[i].gameObject.name == currentWeapon.weaponData.spawnPoint) { //Debug.Log("weaponname: " + currentWeapon.weaponData.weaponName); currentSpawnPoint = spawnPoints[i].gameObject.transform.position; //Debug.Log("currentSpawnPoint: " + currentSpawnPoint); //i += spawnPoints.Length; } } Vector3 direction = (currentSpawnPoint - transform.position).normalized; // - transform.position).normalized; float speed = .2f; gunn.Shoot(currentSpawnPoint, currentWeapon.weaponData.fireSpeed, currentWeapon.weaponData.lifeTime, currentWeapon.weaponData.weaponName, audio); /* * set gun.BulletPrefab * set gun.shootdelay * set direction for gun * set speed of bullet * gun.Shoot(direction, speed); */ }
protected virtual void Update() { cooldown -= Time.deltaTime; // Does the player want to shoot? if (Input.GetButton("Jump") == true) { // Can we shoot? if (cooldown <= 0.0f) { cooldown = ShootDelay; // Shoot left gun? if (LeftGun != null && LeftGun.CanShoot == true) { LeftGun.Shoot(); } // Shoot right gun? else if (RightGun != null && RightGun.CanShoot == true) { RightGun.Shoot(); } } } if (LeftThruster != null) { LeftThruster.Throttle = Input.GetAxisRaw("Vertical") + Input.GetAxisRaw("Horizontal") * 0.5f; } if (RightThruster != null) { RightThruster.Throttle = Input.GetAxisRaw("Vertical") - Input.GetAxisRaw("Horizontal") * 0.5f; } }