05-08-2013, 07:22 PM
Hey everyone,
Basically what I wanted to do is have a light turn on when I walk into a trigger area, then turns off again when the player walks out of that trigger area. Then turns on when they walk back into it and so on and so forth.
Here's my script so far;
So the Spot Light is disabled as soon as the level loads and it turns on fine when the player walks into the trigger area, but it stays on when the player walks out.
How can I script it so the player can walk in and out of the trigger area to make the light go off and on?
Thanks.
Basically what I wanted to do is have a light turn on when I walk into a trigger area, then turns off again when the player walks out of that trigger area. Then turns on when they walk back into it and so on and so forth.
Here's my script so far;
PHP Code:
void OnStart()
{
GiveItemFromFile("lantern", "lantern.ent");
AddEntityCollideCallback("Player", "wrong_door_area", "WrongDoor", false, 1);
SetLightVisible("SpotLight_6", false);
}
void WrongDoor(string &in asParent, string &in asChild, int alState)
{
SetLightVisible("SpotLight_6", true);
}
void OnEnter()
{
}
void OnLeave()
{
}
So the Spot Light is disabled as soon as the level loads and it turns on fine when the player walks into the trigger area, but it stays on when the player walks out.
How can I script it so the player can walk in and out of the trigger area to make the light go off and on?
Thanks.