Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

Set Object Active/Inactive / Set Light On and off

I just wanted to post this here because I took a lot of time figuring this one out.

I had a torch that could be visible and invisible but the light wouldn't stop emitting, I took 3 days to finally stumble upon a very simple solution, instead of repositioning the light far away, I came up with setting them active or inactive. I'll just give the script here if it's okay.

Comments

  • Thanks for posting!

    AC does actually already have a "Light Switch" script - see Section 8.7 of the Manual.  In general it's better practice IMO to disable individual components rather than GameObjects.  Another way to achieve this is to use animations to animate the light's intensity, and then control it using the "Object: Animate" Action.
  • That would be awesome for the torch I use (the animation). The component disabling is good but in my case the torch would be gone along with the fire so I take the whole prefab off by using this code. Thanks for your advice too! :)
  • WARNING: USE MY SCRIPT WITH CAUTION

    Use my script with cutscenes from the scene heirarchy and not from actionlists stored in the project. This is to avoid loss of the objects from the script when loading. I used my script on some actionlists in the project and when I loaded them the scripts have lost the attached objects even when they had constant IDs and parameter IDs, weird but I hope this helps
  • Thanks I will use this =)
  • No problem Kici, I'm glad I could help :smiley:
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.
Do NOT follow this link or you will be banned from the site!