- Home /
[Solved] Update function didn't work
For some reason the script I was trying to access was disabled. Now it works. :/
Probably worth noting that all of the values are set to what you think they would be.
Notice you have errors in the console as well.
Your script most likely throws an exception before Debug.Log("Is Updating");
is called
Answer by The_Three_Vs · Aug 19, 2020 at 10:09 PM
Is the script PathLagReducer or the GameObject it's attached to disabled at any time? Update won't call unless the GameObject is active and PathLagReducer is enabled.
Answer by Glurth · Aug 19, 2020 at 11:19 PM
I notice there are errors hidden in the console. I would suspect one of these in an exception thrown in your Update() function, BEFORE it gets to any of your Debug.Log commands (this would prevent the rest of the function from executing). To test this, you can put another debug log at the very top of the function, and see if that one is visible. I'd also make sure to get rid of all those error messages, or ensure only those which can be safely ignored are showing up. OOPS! Helium said this as a comment 12min ago- sorry Helium!!
$$anonymous$$aybe, but if the AIPath class throws an error when you change the repathRate
|| canSearch
, the exception "bubbles" up to this script and stops it's execution.
Yep, those errors are most likely the problem. Unity stops the scripts if there are certain errors.
As I said, none of the errors are related to the PathLagReducer script or AIPath script. They all come from AIBase, which is an Astar script and all existed before this script. They won't be part of the problem.
This error does NOT imply a coding error exists in the AIBase script, it implies that it's data is not configured properly- a reference that should be provided is missing. We simply don't know enough about your project to assume that AIPath does not depend on / use AIBase, based on the names.. I'd suspect it does. Anyway.. what happened when you put a debug.log at the TOP of Update- do you see it display?
We know these errors are unrelated because they existed before this script existed. Also, moving the Debug.Log to the top worked.
Also should mention we know that errors aren't stopping the scripts execution, because the start function still does what it is supposed to.
But in the Start method, you aren't calling the AIPath.repathRate
.
You should take some time to learn how exceptions work.
Answer by Soxbear · Aug 20, 2020 at 06:05 PM
The script I was trying to access was disabled without me noticing. Thanks for your help. @Glurth @Hellium @Insok @The_Three_Vs
Your answer
![](https://koobas.hobune.stream/wayback/20220613010046im_/https://answers.unity.com/themes/thub/images/avi.jpg)