Forum rules - please read before posting.

Turning a light on and off

Silly problem, just missing something stupid Im sure..
I need to turn a light on when an NPC enters an area and off again when they leave. (It could affect the player too if possible)
I made a trigger area, and put object visibility - visible action on it... targeted the light
disabled the light.. didnt work..

thought, maybe It has to to have been disabled BY AC .. so I turn light on and as first action in OnStart cutscene I use object visibility - invisible
still doesn't work...

What am I doing wrong?
...and when I get it working I presume Ill need 2 actions one for walking INTO the trig and one for walking out (to turn the light out)

M

Comments

  • edited August 2015

    add script Lightswitch to your component and by Trigger enter/exit call object sendMessage turnOff/turnOn.

    yes i would use 2 Trigger for in/out and store the sate in a var.


    Object: Send message Action to call its TurnOn andTurnOff functions to enable and disable it respectively. Similarly, the LightSwitch script can be used to enable and disable Light sources.
























































  • Totally fantastic!

    Everytime I think that theres something forgoton in Adventure Creator, I discover.. ITS BUILT IN!!!
  • One extra thing...
    The above worked great... for switching the light on... but to turn the light off... I need BOTH on enter AND on ext.

    As a hack I surrounded my trigger with other triggers that turn the light off, but its not ideal...
    I thought about having the trigger set a variable instead, but its the same deal, either the var gest set on entry OR on exit.. I cant flip flop..
    Any ideas?
  • edited August 2015

    Well, i would do probably the same.

    var_IsLightOn = false (default)

    Position on enter room:

    tr_SetLightOn (onEnter) - if NOT var_IsLightOn then SendMessage.TurnOn and var_IsLightOn = true

    Position on Exit room:

    tr_SetLightOff (onEnter) - If var_IsLightOn then SendMessage.TurnOff and var_IsLightOn = false






  • edited August 2015
    Well thats basically what I have done (or planned to do if I had turned it into a "variable solution"

    Of course, my explanation of my needs was rather simplistic so its time to explain what I need in greater detail.

    I have a "scanner" in my game, its a plate on the ground surronded by some technology and some lights. When the player walks onto the plate (in reality an AC trigger area) the scanner "scans" the player.

    But as it should also be able to "scan" NPC (or other objects actually, but lets ignore that for now) What happens is that IF I walk int the scanner, the light comes on, and if I walk off, thelight goes out.. GREAT! thats works...
    BUT if I walk into the scanner (and the light comes on) and THEN... before I leave, an NPC (which is working based on some AI) walks onto the scanner plate, the light first switches of briefly (the npc enters the turn off area triggers) then enters the turn on area, the light comes back on.. then they leave (Im still there remember) and the NPC triggers the turn off, and the light turns off.

    What I need is to detect, IS THERE SOMTHING IN THE TRIGGER AREA AT ALL, OF ANY TYPE, if so.. keep the light on, untill there is nothing there.
    So basically I need the ONE single trigger area to do both the detecting of enter AND exiting.
    Which it doesnt, although, Im intrigued what the "continuous" option means really.

    Hope that made sense
    :)

    Mark
  • edited August 2015
    Have you played with the Trigger detects settings in the Trigger Inspector?  By default it's set to just detect the player, but you can set it to detect any object at all - or any object with a set component.  Try changing it to Any Object With Component, and entering the word "Char" into the Component name box.

    Rather than having a Continous Trigger, try having two in the same place - one On Exit, the other On Enter.  Use an integer variable to keep count of the number of characters within it (use the Variable: Set Action to increase/decrease the variable as appropriate).  You can then just check
    if the number >0 at the end of each Trigger's ActionList to
    determine whether or not the light should be on.
  • Will try this now thx
  • edited August 2015
    accidental post
  • Worked.. thanks nice!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.