Hi, I´m trying to write a generic script for turning components on and off depending on if the player can do action X or not. I´m starting basic and just making it based on time from start. This is what I have right now. If I use the variable it gives me this error "Assets/activate script.js(6,13): BCE0023: No appropriate version of 'UnityEngine.Component.GetComponent' for the argument list '(UnityEngine.Component)' was found.". But if I type the name of the component it works just fine. Is there a way to use a variable component so I can use this same script in multiple places?
not sure you're making this the best way, but to help you out right now: Code (csharp): var test:Component; var time:int; function Start () { yield WaitForSeconds(time); GetComponent(test.GetType()).enabled = false; } note that I added "GetType()" after your component, and changed from active to enabled.
Thanks fox, I retyped active and not enable so that was my mistake... Your script worked perfectly though. Thanks One example of where I am putting this is when the player comes on screen. I don´t the player to have control right away until the avatar has done their entrance. This way the player has no control until the script is enabled.