Felt I had fixed during challenge

Hi guys,

So during the challenge to try and fix this bug ourselves I felt I had fixed it by simply switching 2 lines around in my Start method on my base stats script. I noticed that we were calling to calculate level, which requires experience, before we were Getting our experience component. I tested it and not once did the bug happen.

Am I right to assume that this has in fact fixed the bug or was this just too simple thinking?

It may have fixed it in the short term, but only because the race condition went in the right order. You can’t always guarantee it will…

Simple strategies for avoiding these conditions:

Awake() is for caching external references, but never acting on those cached references.
OnEnable() is where you will subscribe to events
Start() and Update() are where you can access cached references
OnDisable() is where you unsubscribe to events you added in OnEnable

2 Likes

Good basics here Brian Thanks!!!

Awake() is for caching external references, but never acting on those cached references.
OnEnable() is where you will subscribe to events
Start() and Update() are where you can access cached references
OnDisable() is where you unsubscribe to events you added in OnEnable

I remember Rick had also explained the difference between Awake and Start
But in this class we have not been following basics as much as desired.

Your simple strategies are concise and to the point and seem like part of Basics!
again thanks

Yes, it’s typical in prototyping to get the code working, and then go back and make it “pretty” and ready for interaction… I was a pretty experienced c#/Unity programmer before I took the course (Yep, I was a student, before I was a TA), so I applied those rules as I went. Saved me a lot of refactoring time. That being said, learning refactoring is also a part of this course.

1 Like

Privacy & Terms