void CmdTurretFire(Vector3 offset, Vector3 direction, float speed) { var bullet = (GameObject)Instantiate( bulletPrefabs[2], transform.position + (offset) + direction * 2, Quaternion.identity); BulletStandardDestroy bulletScript = bullet.GetComponent <BulletStandardDestroy>(); bullet.GetComponent <Rigidbody>().velocity = direction * speed; bulletScript.owner = this; NetworkServer.Spawn(bullet); }
void Update() { if (!isLocalPlayer) { return; } if (NetworkGameManager.gameover) { return; } if (controlsLocked) { return; } if (hasShootingInput()) { bulletScript = bulletPrefabs[bullet].GetComponent <BulletStandardDestroy>(); if (Time.time > bulletScript.rateOfFire + lastShot) { CmdFire(bullet, bulletOffset, bulletDirection, bulletScript.bulletSpeed); lastShot = Time.time; audio.clip = fireSound; audio.Play(); } } if (hasSecondaryShootingInput() && hasSpecialSkill) { checkSpecialSkill(); } if (isGrounded && (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Joystick1Button0) || Input.GetButtonDown("Jump"))) // joystick button 4 LB { Jump(); } if (Input.GetKeyDown(KeyCode.Backspace)) { toggleLethalBullets(); } if (isAbleToTackle && (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetButtonDown("Rush"))) { Tackle(); } switchCurrentBullet(); if (hasStopped()) { timeWithoutMovement += Time.deltaTime; } else { timeWithoutMovement = 0.0f; } if (hasStopped() && timeWithoutMovement > 3.49f) { rollNewSpecial(); } if (hasTurret && hasShootingInput()) { fireTurret(); } if (timeWithoutMovement > 3.5f) { timeWithoutMovement = 3.5f; } }