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.
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.
I can solve the first two issues, but I don’t use VSCode so can’t help you with that
The code you used is not valid. You are missing some parentheses. It should be FindObjectOfType<PlayerController>().DisableControls();
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);
}