Hello there,
I’ve noticed this odd behavior, despite my code matching that of the resources, but went through and finished the project in hope this bug would be later identified. No luck.
The thrusting sound works perfectly. It appears somehow that the “death” and “win” sounds only play if I die/win while hitting the space bar; i.e., while thrusting. Otherwise, it is silent. The particle effects are working without issues although they are in the same method.
Again, I figured this would be a bug due to Unity version 2018.4.13f1. However, I loaded the project from Udemy resources and the sounds seem to work just fine there, although the code is the same.
Any clues there?
private void RespondToThrustInput()
{
if (Input.GetKey(KeyCode.Space)) //Can Thrust while rotating
{
ApplyThrust();
}
else
{
audioSource.Stop();
mainEngineParticles.Stop();
}
}
The else block gets executed if the if-condition was not evaluated to true.
What you could do is to wrap the RespondToThrustInput() and RespondToRotateInput() method calls in Update into an if block. The condition would be the state, which should be State.Alive.
Yess!!1 Super thanks Nina, this solved the problem. Finally I can hear the jiggle sound.
Indeed, the RespondToThrustInput was being executed at all times and when I am not Thrusting, sound would stop. Didn’t catch that before. Thanks again.