If there is a gameobject I want to find with a tag, I want it to run the “if” command if it appears in the hierarchy. If it does not, I want it to run the “else if” command, but whatever I did, I could not run the “if” command.
Now you can print FoundCube using Debug.Log() and see if THAT is your problem.
This is how you debug a program.
In fact, to help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.
Doing this should help you answer these types of questions:
is this code even running? which parts are running? how often does it run?
what are the values of the variables involved? Are they initialized?
Knowing this information will help you reason about the behavior you are seeing.
Sir my English is not very good, I try to explain myself as much as I can. I am sorry about this.
I used Debug.Log () and if doesn’t work only else if works. I’m asking for help because I can’t understand why if doesn’t work.
When the gameobject tag linked to the name cube_Tag_Name is active in the game, it does not run if, but when the gameobject tag linked to the cube_Tag_Name name is not active in the game, it runs if else.