Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Turning light on and off in trigger area?
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#1
Turning light on and off in trigger area?

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;

PHP Code: (Select All)
void OnStart()
{

GiveItemFromFile("lantern""lantern.ent");

AddEntityCollideCallback("Player""wrong_door_area""WrongDoor"false1);

SetLightVisible("SpotLight_6"false);

}

void WrongDoor(string &in asParentstring &in asChildint 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.
05-08-2013, 07:22 PM
Find
ClayPigeon Offline
Member

Posts: 214
Threads: 13
Joined: Mar 2012
Reputation: 8
#2
RE: Turning light on and off in trigger area?

AddEntityCollideCallback("Player", "wrong_door_area", "WrongDoor", false, 1);
AddEntityCollideCallback("Player", "wrong_door_area", "WrongDoor", false, -1);

void WrongDoor(string &in asParent, string &in asChild, int alState)
{
    if(alState == 1) {
    SetLightVisible("SpotLight_6", true); }
    else if(alState == -1) {
    SetLightVisible("SpotLight_6", false); }
}
(This post was last modified: 05-08-2013, 08:18 PM by ClayPigeon.)
05-08-2013, 08:17 PM
Find
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#3
RE: Turning light on and off in trigger area?

(05-08-2013, 08:17 PM)ClayPigeon Wrote:
AddEntityCollideCallback("Player", "wrong_door_area", "WrongDoor", false, 1);
AddEntityCollideCallback("Player", "wrong_door_area", "WrongDoor", false, -1);

void WrongDoor(string &in asParent, string &in asChild, int alState)
{
    if(alState == 1) {
    SetLightVisible("SpotLight_6", true); }
    else if(alState == -1) {
    SetLightVisible("SpotLight_6", false); }
}

That didn't work sadly, the light still turns on, but stays on when I walk around away from that area Sad.
05-08-2013, 08:47 PM
Find
ClayPigeon Offline
Member

Posts: 214
Threads: 13
Joined: Mar 2012
Reputation: 8
#4
RE: Turning light on and off in trigger area?

AddEntityCollideCallback("Player", "wrong_door_area", "WrongDoor", false, 0);

void WrongDoor(string &in asParent, string &in asChild, int alState)
{
    if(alState == 1) {
    SetLightVisible("SpotLight_6", true); }
    else if(alState == -1) {
    SetLightVisible("SpotLight_6", false); }
}
Should work now
(This post was last modified: 05-08-2013, 08:54 PM by ClayPigeon.)
05-08-2013, 08:53 PM
Find
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#5
RE: Turning light on and off in trigger area?

(05-08-2013, 08:53 PM)ClayPigeon Wrote:
AddEntityCollideCallback("Player", "wrong_door_area", "WrongDoor", false, 0);

void WrongDoor(string &in asParent, string &in asChild, int alState)
{
    if(alState == 1) {
    SetLightVisible("SpotLight_6", true); }
    else if(alState == -1) {
    SetLightVisible("SpotLight_6", false); }
}
Should work now

Perfect! Thank you very much! Now I'm just going to add sound to it as well!
05-08-2013, 08:56 PM
Find




Users browsing this thread: 1 Guest(s)