CS0642: possible mistaken empty statement

Hello guys I’m fairly new. I had received this error while doing the step by step tutorial. Can anyone help me understand? (16,45)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DestroyOutOfBounds : MonoBehaviour
{ private float topBound = 30;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
if (transform.position.z > topBound);
{ Destroy(gameObject);

}

}
}

I’m still new sorry.

Just a typo, your if statement has a ; at the end of it. Remove it.

1 Like
if (transform.position.z > topBound);

should not have a semicolon.
Please use code tags when placing code in your post. Its also helpful when you provide more info on your issue. you only have 2 lines so it jumps out. I know you’re new, so just letting you.

Also, read the compile errors messages and try to make sense of them.
(16,45) means the 45th character on line 16 is where your issue is, and it probably mentioned the semicolon. Even veterans make these typos, but catch them instantly just because the compiler yells at them.

2 Likes

Thank you I didn’t realize this. also I never knew what the numbers mean just that it was there now I know.

1 Like

Here’s the cribsheet:

Remember: NOBODY here memorizes error codes. That’s not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

The complete error message contains everything you need to know to fix the error yourself.

The important parts of the error message are:

  • the description of the error itself (google this; you are NEVER the first one!)
  • the file it occurred in (critical!)
  • the line number and character position (the two numbers in parentheses)
  • also possibly useful is the stack trace (all the lines of text in the lower console window)

Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

Look in the documentation. Every API you attempt to use is probably documented somewhere. Are you using it correctly? Are you spelling it correctly?

All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.