// Update is called once per frame void FixedUpdate() { if (jetpack.UsingJet) { audioPlayer.PlaySound(JetAudioClip, Volume); } }
/// <summary> /// Shoots the projectile in direction of player. /// </summary> public void ShootProjectile() { var projectile = ObjectManager.instance.GetObject(Projectile.name, ProjectileSpawnLocation.position); var projRigidbody = projectile.GetComponent <Rigidbody2D> (); if (!projRigidbody) { Debug.LogError("Projectile should have Rigidbody2D attached"); return; } var heading = player.position - transform.position; var distance = heading.magnitude; var direction = heading / distance; projRigidbody.AddForce(direction * ProjectileForce); _audio.PlaySound(ShootAudioClip, 1f); }
void Start() { _audio.PlaySound(BackgroundAudioTracks [Random.Range(0, BackgroundAudioTracks.Length)], Volume, true); }
/// <summary> /// Burst moves towards the player. Called by animation. /// </summary> public void BurstMoveTowardsPlayer() { _rigidbody2D.AddForce((player.position - transform.position).normalized * (MoveBurstForce * Time.deltaTime), ForceMode2D.Impulse); _audio.PlaySound(MoveAudio, 0.5f); }
/// <summary> /// Plays the audio clip when enemy activates. /// </summary> public void PlayNearbyAudio() { _audio.PlaySound(PlayerNearbyAudio, 1f, Random.Range(0.6f, 1.6f)); }
/// <summary> /// Kill the specified enemy and applys knockback force. /// </summary> /// <param name="projectilePosition">Projectile position.</param> /// <param name="force">Force.</param> public void Kill(Vector3 projectilePosition, float force) { _audio.PlaySound(SoundOnDeath, 0.8f); startTime = Time.time; RepelFromPositionWithForce(projectilePosition, force); }
private void OnCollectiblePickUp(CollectiblePickedUpEvent e) { _audio.PlaySound(PickUpAudio, 0.5f); _light.intensity += e.LightAmount; _light.range += e.RadiusAmount; }
/// <summary> /// Plays the explosion sound. /// </summary> public void PlayExplosionSound() { _audio.PlaySound(ExplosionClip, 1f); }
/// <summary> /// Plays random clip on player step. /// </summary> public void PlayStepAudio() { var stepSound = StepClips [Random.Range(0, StepClips.Length)]; audioPlayer.PlaySound(stepSound, 0.8f); }