I took the solution from this yt video, basically you need a second audio source in the game object, as there is one already being used for the main engine. So the Stop method shuts it off, and then if you want to start it/shut it off while you’re rotating, it becomes a complete mess.
[SerializeField] AudioClip mainEngine;
[SerializeField] AudioClip sideEngine; // add a separate variable for the side engine clip
AudioSource engineSFX;
AudioSource sideEngineSFX; // separate variable for second audio source
void Start()
{
rb = GetComponent<Rigidbody>();
engineSFX = GetComponent<AudioSource>();
sideEngineSFX = gameObject.AddComponent<AudioSource>();
// on game start add a second audio source to the game object, which the script is attached to
}
ApplyRotation(rotationValue);
if (!leftThruster.isPlaying)
{
leftThruster.Play();
}
if (!sideEngineSFX.isPlaying)
{
sideEngineSFX.PlayOneShot(sideEngine); //use the 2nd source with side engine clip
}
private void StopRotationEffects()
{
rightThruster.Stop();
leftThruster.Stop();
sideEngineSFX.Stop(); // stop the sound playback on the 2nd source
}