Two last lessons for Snowboarder

I have 2 problems with this chapter.

  1. FindObjectOfType.DisableControls(); — it doesn’t work, in compiler it gives me a mistake, and I’ve tried to fix some things in PlayerController naming, then reload, and it didn’t help. So that is why it is commented out, otherwise it doesn’t start.
  2. The part with the duplications of sounds and effects is done exactly as Rick said, but it still duplicates in the game. I really don’t understand what the problem is.

And I have an additional question, not sure where to ask. I would like to have those nice suggestions from Visual Code, I think I have all the right add-ons installed, but it’s not the same and I have to write and watch everything on my own.
image

I can solve the first two issues, but I don’t use VSCode so can’t help you with that

  1. The code you used is not valid. You are missing some parentheses. It should be
    FindObjectOfType<PlayerController>().DisableControls();
  2. Your if statement is not valid. The code inside the braces will always execute because you have a ; after the if. That terminates the if's scope. Remove the ; at the end of the line.

The fixed code should look like this

if (other.tag == "Ground" && !hasCrashed) // <- no ;
{
    hasCrashed = true;
    FindObjectOfType<PlayerController>().DisableControls(); // <- note the parentheses
    crashEffect.Play();
    GetComponent<AudioSource>().PlayOneShot(crashSFX);
    Invoke("ReloadScene", DellayCrash);
}

Hi Julia,

Regarding the problem(s) with VS Code, you could take a look at this thread:


See also:

You are amazing, thank you very much!

It seems to work!
Thank you, Nina, you are great!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms