Hi guys.
I would like to reduce “Motore2” when I press Key A, and reduce “Motore1” when I press Key “D”. How can I add this?
using UnityEngine;
using System.Collections;
public class Audio : MonoBehaviour
{
public AudioClip Motore1;
public AudioClip Motore2;
float soundPitch = 0;
float maxSpeed = 2;
float minSpeed = 0.2f;
void Start()
{
if (!audio.playOnAwake) audio.Play();
}
// Update is called once per frame
void Update ()
{
soundPitch = Mathf.Clamp(soundPitch, minSpeed, maxSpeed);
if (Input.GetKey(KeyCode.A))
{
audio.clip = Motore1;
soundPitch+= 0.09f;
audio.pitch = (soundPitch);
}
if (Input.GetKey (KeyCode.D))
{
audio.clip = Motore2;
soundPitch+= 0.09f;
audio.pitch = (soundPitch);
}
if (Input.GetKey (KeyCode.S))
{
soundPitch-= 0.09f;
audio.pitch = (soundPitch);
}
}
}