Basically I want the lights/torches in a room to light up when the player enters the room.
If I have just a standard flame(particle effect) in the room then the following code works fine
(flame appears on enter and disappears on exit)
#pragma strict
var flame : GameObject;
function Start ()
{
flame.SetActive(false);
}
function OnTriggerEnter()
{
flame.SetActive(true);
}
function OnTriggerExit()
{
flame.SetActive(false);
}
Moving on I now have a nice model of a medieval torch with the flame effect attached but I get nothing when entering or exiting the trigger area ?
I found some info that said its because SetActive doesnât work with Objects/Transforms so I tried usingâŚ
#pragma strict
var torch : GameObject;
function Start ()
{
torch.enabled = false;
}
function OnTriggerEnter()
{
torch.enabled = true;
}
function OnTrigerExit()
{
torch.enabled = false;
}
âtorchâ being the name of the parent object, but this just gave an error message.
Any ideas please guys?