Forum rules - please read before posting.

How to use RememberHotspot script?

edited December 2016 in Technical Q&A
I found that to determine wether a hotspot is on or off when the game starts, use this script:

AC_OnOff AC.RememberHotspot.startState = AC_OnOff.On

but how do I choose if the hotspot would be on/off when the game starts?

Thank you!
edit:
I found the tutorial of putting script on hotspot and they said put using AC; at the very top, so should I delete the rest of the scripts or just put it on top of all of them?
image

Comments

  • I want to delete everything below "edit:"
    but it said i don't hv permission to edit?
  • edited December 2016
    imageimageimagei tried using these stuff but not working
    here is what happened when i pressed playimage
  • imagesince i can't edit my posts for some reason heres an updated fail
  • edited December 2016
    Wish you'd just copied the text it would been easier to edit, like this I have to retype everything...

    Anyway, your uh... mutilating the script. First off the brackets define Clauses or Blocks in scripting, and your Class doesn't have an ending bracket. Second those AC lines need to be run inside a function. 

    also the line:

    AC_OnOff AC.RememberHotspot.startState = AC_OnOff.On

    the first word means that the method returns an AC_OnOff when read (probably an enum, which is like an enumeration of categories). The AC.RememberHotspot is telling you the type of class that can use the method/variable (in this case startState is a variable or property), the last part tells you that you need to give this variable that kind of data when you want to write in it. Now, I can't recall but AC:RememberHotspot it's most probably referring to the remember hotspot script, meaning that your objects is going to need one of those so you can get a reference to it.  So pick the objects with your hotspots and add them the remember hotspot script. Then replace the code in your example script to the following:  

    using AC;
    using System;
    using UnityEngine;

    public class bucket2hotspot : MonoBehaviour
    {
       private AC.RememberHotspot _rememberScript;

       void Start()
       {
            //get a reference for the remember script.
            _rememberScript=GetComponent<AC.RememberHotspot>();

    //check its startState
            if(_rememberScript.startState==AC_OnOff.On)
            {
                //do something
                Debug.Log("State was: " + _rememberScript.startState);
            }
       }
    }

    PS: The code is untested so let me know if you get any errors.
  • edited December 2016
    Hello!
    Thank you so much and sorry about that!
    I got this message from the console

    NullReferenceException: Object reference not set to an instance of an object
    AC.StateHandler.Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:247)

    NullReferenceException: Object reference not set to an instance of an object
    AC.MainCamera._LateUpdate () (at Assets/AdventureCreator/Scripts/Camera/MainCamera.cs:473)
    AC.StateHandler.LateUpdate () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:438)

    NullReferenceException: Object reference not set to an instance of an object
    AC.StateHandler.OnGUI () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:509)



    Also all I have to do is replace whatever is on screen in the script editing with that script you told me right?
    (sorry I have no coding experience except the very basics in excel last year in 9 th grade lol)

  • @Alverik's script is fine - be sure to only run this script if you're in an AC-powered scene though.
  • works!
    I must've forgotten to delete previous fail scripts

    Thanks!
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.