Looping is Off
[SerializeField]AudioClip mainEngine;
[SerializeField]ParticleSystem LeftThrust;
[SerializeField]ParticleSystem RightThrust;
[SerializeField]ParticleSystem MainThrust;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
audioSource = GetComponent<AudioSource>();
}
// Update is called once per frame
void Update()
{
ProcessThrust();
ProcessRotation();
}
void ProcessThrust()
{
if (Input.GetKey(KeyCode.Space))
{
rb.AddRelativeForce(Vector3.up * Thrust * Time.deltaTime);
// audio settings
if (!audioSource.isPlaying)
{
MainThrust.Play();
audioSource.PlayOneShot(mainEngine);
}
else
{
MainThrust.Stop();
audioSource.Stop();
}
}
}
void ProcessRotation()
{
{
if (Input.GetKey(KeyCode.A))
{
LeftThrust.Play();
FrameRotation(rotationSpeed);
}
else if(Input.GetKey(KeyCode.D))
{
RightThrust.Play();
FrameRotation(-rotationSpeed);
}
else
{
LeftThrust.Stop();
RightThrust.Stop();
}