Hello everyone,
Was having a wonderful time working away on my game until I came up with a wierd problem. Some of the functionality I implemented wasn’t working. No big deal, so I attempted to fix it. Problem was, there was no problem, at least not that I could see. I spent a good 2-3 hours trying to fix it, until I finally figured it out: the update function had stopped working. My question is, why? It appears to only be an issue with this one script file, but I still want to know. If the update function has the ability to just shut down on me randomly, that’s kind of concerning.
Literally, this code doesn’t work. It only runs once. Not once per frame, just literally once, like the Start() function. Yet it works in my other script files. Why?
public class AIScript : MonoBehaviour
{
void Update()
{
print("Is this working?");
}
}
There’s only one thing I can think of that was different for this script file. When I first created it, I gave it a name with spaces (like “This Script File” instead of “ThisScriptFile”). So naturally I got a “The class name does not match the file name” error. Fixed it easily by removing the spaces in the file name. Could that have somehow caused the update function to break?
EDIT*
Turns out the problem was I had accidentally turned “collapse” on in the console. Nothing wrong with the update function. Can’t believe it took me that long to figure it out.