Can anyone tell me why the Door isn't turning up as a gameObject in the script in the inspector? I'm probably doing something stupid, but I've tried 20 different combinations to make it work and it still resides in this half-dark inaccessible font, (i.e, I can't drag an object from the hierarchy to the inspector). The animation is legacy. It plays if I tick play automatically. Just can't get the Player to trigger the animation.
you can use Door = this.gameObject as the script is already attached to the GameObject Door . try making the Door to public variable and drag and drop the GameObject "Door" to the Script . Finally get the animation component using get component function . Then play the clip Door.GetComponent<Animation>().Play("Take 001");
You're in Debug Mode Inspector ; Select "Normal". And your variable is private, so you can do nothing from the inspector. Set it as public if you want to drag something in. Edit: this is kind of stupid to do that if you want to have the current gameObject 'cause you already have a variable named "gameObject" inherited from MonoBehaviour.
It won't show up in the inspector as you're assigning it at runtime. The reason it's shown as inaccessible is it's a private variable and you have the inspector in "Debug" mode. If you change the inspector back to normal mode, you won't see the variable at all.
many thanks codezero, Thanks so much for your help. I thought I understood how to do this, and then tried to quickly do it again and ran into three hours of pain. Probably a common experience in coding.
Its a good practice I would say, you make mistake and learn from it so you will never re do the mistake again . have a good time coding buddy and remember this community is always here to help you .