Forum rules - please read before posting.

Turn on light with an animator

Hi there,

I've been trying to turn on a light using an animator, as I've seen suggested in the forum and in Chris' prefab puzzle video. I should be close but cannot figure the last bits out.

Basically, I have a Light 2D object, an Animator Controller with two states (on & off) and a bool variable (IsLightOn) attached to it. I have a sprite with a hotspot that changes the value of the IsLightOn boolean on use. What I reckon I'm missing—sadly it's not shown in your prefab puzzle mentioned above—is the actual Animations associate with the Animator Controller's two states. I don't have scripting experience with Unity but I guess here is where the intensity of the light is modified based on IsLightOn.

Sorry for the naive question and thanks in advance!

Comments

  • Welcome to the community, @peri.

    Having the light turn on/off based on the animaton state is a case of animating the Light Inspector's "Intensity" property within those states. This doesn't involve scripting, nor strictly AC, but is a case of working with Unity's Animation window.

    An example of this can be found in Unity's docs here.

    You're welcome to share images if you get stuck, but the first thing to make sure is that your Animator component is attached to your Light GameObject. You should then be able to animate any property associated with that GameObject as part of its AnimationClips.

  • Hi Chris, I got it working now!

    Sorry, I didn't realise this was not related to AC. I'm having great fun with AC and will continue exploring.

    Thanks again.

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.