Add various sound effects

This commit is contained in:
2019-10-03 00:38:52 +02:00
parent 4bb1730091
commit db9116cfdc
22 changed files with 983 additions and 1 deletions

View File

@@ -14,9 +14,15 @@ public class PlayerController : MonoBehaviour
public float boostDuration = 0;
public float lastBoostTime = 0;
public bool lockBoost = false;
public AudioClip boostSound;
public Vector2 pitchModifier;
private AudioSource audioSource;
// Start is called before the first frame update
void Start()
{
this.audioSource = this.forceZone.transform.GetComponent<AudioSource>();
this.rb = GetComponent<Rigidbody>();
}
@@ -27,7 +33,7 @@ public class PlayerController : MonoBehaviour
float movementDirection = Input.GetAxis("Vertical" + this.playerNumber);
if (this.useController) {
Debug.Log(Input.GetAxis("VerticalBack" + this.playerNumber));
//Debug.Log(Input.GetAxis("VerticalBack" + this.playerNumber));
movementDirection = Input.GetAxis("VerticalBack" + this.playerNumber) > 0 ? -1 : movementDirection;
}
@@ -58,8 +64,11 @@ public class PlayerController : MonoBehaviour
//Boost
if (Input.GetButtonDown("Boost" + this.playerNumber) && !this.lockBoost)
{
this.audioSource.clip = this.boostSound;
this.audioSource.pitch = Random.Range(this.pitchModifier.x, this.pitchModifier.y);
this.rb.AddRelativeForce(Vector3.forward * this.boostSpeed * Time.deltaTime, ForceMode.Impulse);
this.forceZone.SetActive(true);
this.audioSource.Play();
this.lastBoostTime = Time.time;
this.lockBoost = true;
}