Forum rules - please read before posting.

Turn on a light?

I'm new to AD and was wondering if there was a simple way to enable a light when clicking a hotbox? I know how to do this with code, but was wondering if AC has a simple option.

Comments

  • AC includes a "Light Switch" component that can recieve Turn On / Turn Off messages via the Object: Send message Action - please see the Manual's Section 8.8.

    A tutorial on saving a light's enabled state through a custom save script can be found here.
  • Is there a simple way of creating an If-then statement using the node editor to create the on-off effect without scripting? So for instance, when the light is turned on, AC changes a bool or variable to tell the node editor the light is on, then when clicked again, it checks if the bool is enabled or disabled and runs the proper set of nodes?
  • Scripting is only required if you want the light's state to be stored.

    You can declare variables - both local (per scene) and global (per project) in the Variables Manager.  They can be accessed and set at runtime using the Variable: Check and Variable: Set Actions - no need to script them.  For more, please see the Variables chapter of the Manual.

    An alternative way to control a light, without scripting or the Light Switch component, is to animate the light's intensity using the Animator component.  Animation playback can be controlled via the Object: Animate Action, and its state can be saved with the provided Remember Animator component.
  • edited April 2019

    I am attempting to use Turn On / Turn Off messages via the Object: Send message Action, I get an error "Sendmessage TurnOff has no receiver!"

    I have tried using light like a prefab with still no success.

  • Have you attached the LightSwitch component to the object you're sending messages to? That contains the "TurnOff" method that the Action should be triggering.

  • I didn't know about the light switch component. I've been hacking this by using a variable to check the on/off state and then teleporting the light itself into place or far offscreen somewhere!

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.