Hi ! Here is the flashlight script im using, made from a youtube tutorial, its working but have some strange behavior . Light is turning on and off, the console say this UnityEngine.Component.active' is obsolete. the active property is deprecated on Components. Please use gameObject.active instead. If you meant to enable / disable a single Component use enabled instead. The Message is pretty easy too understand i try too use enabled and gameobject.active instead, i get 0 errors but light is not turning on and off. So maybe im missing something, Any help would be appreciated. Im New too Programming but im trying too learn. Code (csharp): var lightOfEpicness : Transform; var clickAudio : AudioClip; function Start () { } function Update () { if(Input.GetKeyUp(KeyCode.T)){ audio.clip = clickAudio; audio.Play(); if(lightOfEpicness.active == true){ lightOfEpicness.active = false; } else { lightOfEpicness.active = true; } } }
Thanks for the fast reply, i will try to remove Transform and use GameObject instead, hopefully it will work !
Here an update on the script, GameObject work well, i also updated the obsolete gameobject.active. One more question How can i update this line With the new active code? I tried using Set.Active(true) but im probably missing something here, please help, thanks ! if(lightOfEpicness.active == true){
.activeSelf or .activeInHierarchy http://docs.unity3d.com/Documentation/ScriptReference/GameObject-activeSelf.html