Forum rules - please read before posting.

[SOLVED] Fire Alarm blinking light

edited May 2014 in Technical Q&A
I am trying to make a cut scene where  after a bool flag is set to true from a triger a red light starts to blink like an alarm situation. I have tried using the Object enable and Object visible actions but all i get is the light to be either blinking fast uncontrollably or the light to be there static even before the triger  is activated. Any help?

Comments

  • If don't work this way, try make a simple script for the light and use the action: Send Message for this script.
  • edited April 2014
    I am not really sure how to use the Send Message with an outside of AC script. I get an error TurnOn has no receiver!
  • If you send a TurnOn message to a script, you have to be sure that such a script has a TurnOn function!  Most AC prefabs have functions like this, Interact, TurnOff etc, but a custom script will have to have the same.

    Rather than having a custom script, you may be able to get what you need by making a Cutscene that runs in the background.  Something like a Visible (off), Pause, Visible (on), Pause, Variable Check loop should do the trick.
  • It worked @ChrisIceBox :) thanks man you rock
  • i need to swich objects on and off. so i made a script.
    the TurnOff function works fine. but i still get an eror message for the TurnOn function...

    my code:

    using UnityEngine;
    using System.Collections;
    using AC;

    public class TurnOnAndOff : MonoBehaviour {
        
        public void TurnOn()
        {
            gameObject.SetActive(true);
        }
        public void TurnOff()
        {
            gameObject.SetActive(false);
        }
       
        
    }

    i tryed to send a cutom message to my TurnOn function. but i get the same resolt...
    is it named difrentlly? i spose not... what am i doing wrong?

  • by the wey, you (the outher) shuld defenetlly add a script like this, or atleast a simple option threw the action list, to turn on and off objects in the scene. i belive that that's a nessesity. not complaning thow :)
  • Corection.  it seems that the Off function can work only once on an object. the second time i tryed, i get the same error massege (Only with the name "TurnOff" for the 'missing' function).

    i ment the last comment in a good helpful way, not in any other way. i love AC, and my love 
    growes as i lern more and develop :)
  • Once a GameObject is disabled, Unity has trouble find it again, hence the error message.

    This is why AC does not come with such a script.  Instead it is better to disable individual components on an object, or remove it from view with the Object: Visibility or Object: Teleport Actions.

    If your script is there to control a light, for example, your TurnOff function could instead be:
    GetComponent ().enabled = false;
  • ok. so abowt that, enabling object components, i have one camera that reanders to a reander matirial, and i need it working in the background. and the camera component is disabled on scene play. i tryed to make it active thugh an action list, but it stays disabled....

    so what exaclly does the object:TurnOn action do?...
  • it used in the 3d tutorial, but on an AC trigger..
    this ishue is a bit of a problem for me, becouse i have a realistic efects pacage, that are starting to act upon enabling the object...
  • i belive i can just crate them at run time and distroy them at the right time... yap, that's one salution :)
  • Hello everyone!

    I'm trying to make a blinking lights as like as light alarm.

    The idea I would have:

    - At the beginning of the game, this lights are OFF. I understand that on my Cutscene OnStart I must indicate that this object are invisible. As they are two lights (alarm1 and alarm2) I have incorporated them into a Empty Object (Alarm Lights), so that I indicate affects children. 



    - When I cross a Trigger and I doesn't have the correct item (define by Variable) the lights blinked (Turns Visible and Invisible).



    I would like try to make this with AC system from comments of Chris, because I don't have any programming knowledge. 
    But what I have realized doesn't work. I have missed something, wrong?

    Thanks.

  • The "Object: Visibility" Action affects Renderer components - i.e. meshes and sprites - not Lights.  To control a light through ActionLists, attach the included Light Switch component to it - see the "Light Switch" chapter of the Manual.
  • Hi Chris,

    works fine! 

    Last question: how I can repeat or loop this effect X times I want?

    Thanks
  • You can loop Actions back on themselves, pausing them with an Engine: Wait Action if necessary.  The ActionList: Kill Action can also be used to have a separate ActionList (e.g. a Trigger) stop it from running.

    An integer variable can keep track of how many times you run a loop by increasing its value each time (Variable: Set) and seeing if it's reached a maximum value (Variable: Check).

    Then again, it's also possible to just animate the light's enabled state / intensity with Unity's standard Animator system.  AC can control the playback of Animator components with the Object: Animate Action.  With that technique, you wouldn't need to use the LightSwitch nor have a looping ActionList to turn it on/off in a cycle, as that would be all controlled through animation.
  • I have opted for the first option since I have been the fastest to do.
    Many thanks Chris.
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.