You renamed the method. The string didn't notice.

The problem
A method name in quotes.
void Die(){ Invoke( "Respawn", 3f );} // renamed from Respawn last weekvoid RespawnAtCheckpoint(){ transform.position = checkpoint;}
It still compiles. You find out when you play, from an error in the console.
The fix
Let the compiler write the string.
nameof turns a name into its string when you build. Rename the method, and the string follows.
nameof( Respawn )→"Respawn"
The fix in code
Checked, and renamed with you.
void Die(){ Invoke( nameof( RespawnAtCheckpoint ), 3f );}
Misspell it and it won't compile. Rename it in your editor and this changes too.
Same trick
Anywhere a name hides in a string.
If a string has to match a name in your code, nameof keeps them together.
- Invoke, StartCoroutine
- nameof( Method )
- Error messages
- nameof( amount )
- Change callbacks
- nameof( OnChanged )
The rule
A name in quotes? Use nameof.
- Instead of
- "Respawn"
- Write
- nameof( Respawn )
- You get
- a compile check