Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialStewart Fortier
Courses Plus Student 579 PointsDoes the .enabled variable simply control whether Update() is called on a given Object?
When we set birdMovement.enabled = false, does that just prevent the BirdMovement object from calling its Update() function until we set enabled = true?
Is there anything else that is affected by setting "enabled" as true or false on a given object?
1 Answer
Ben Reynolds
35,170 PointsIt would be the same as selecting the Bird object in the hierarchy, then unchecking the box next to "Bird Movement (Script)" in the inspector panel. So it will disable the whole BirdMovement script, not just the Update method.
Since we're only setting the enabled property on one of the object's components and not on the entire object itself, the other components should not be affected (as long as they don't depend on something in the disabled script). For example the bird can't move until the game starts, but its idle animation will still play.
Stewart Fortier
Courses Plus Student 579 PointsStewart Fortier
Courses Plus Student 579 PointsGot it, thank you!