My code, whilst working for some parts wont work if I have it the exact same way for others.
In the example below to get the particle effect in my landing sequence to play I cannot have them inside an if statement, yet when going through with Rick I needed to put the main booster particles in an if statement.
private void StartLanding()
{
rb.AddRelativeForce(Vector3.up * landingThrust * Time.deltaTime);
if(!audioSource.isPlaying)
{
audioSource.PlayOneShot(landingAfterBurner);
}
landingBoosterParticles.Play();
Debug.Log("afterburners are burning");
}
private void StopLanding()
{
landingBoosterParticles.Stop();
Debug.Log("afterburners stopped burning");
}
private void StartThrust()
{
rb.AddRelativeForce(Vector3.up * mainThrust * Time.deltaTime);
if (!audioSource.isPlaying)
{
audioSource.PlayOneShot(mainEngineThruster);
}
if (!mainBoosterParticles.isPlaying)
{
mainBoosterParticles.Play();
}
}
private void StopThrust()
{
audioSource.Stop();
mainBoosterParticles.Stop();
}
I’m not understanding as when we created the left and right booster particle effects, they also needed to to inside an if, else statement the same as the mainThrusterParticles.
private void RotateLeft()
{
ApplyRotation(rotationThrust);
if (!leftBoosterParticles.isPlaying)
{
leftBoosterParticles.Play();
}
}
private void RotateRight()
{
ApplyRotation(-rotationThrust);
if (!rightBoosterParticles.isPlaying)
{
rightBoosterParticles.Play();
}
}
private void StopRotation()
{
leftBoosterParticles.Stop();
rightBoosterParticles.Stop();
}
also my audio for my after burners doubles up and I get that disgusting clicking sound. Rick’s fix for this
was to create the else statement audioSource.Stop(); method call. Yet when I do this It causes my mainEngineThruster audio clip to not play anymore and I still get the double up of sound on the afterburners sound clip. This has caused me to not go ahead and add the sound to the left and right turn thrusters, even though Rick claimed that we should already know how to do it as we went over it earlier in the course.