Forum rules - please read before posting.

Switch on /off enable hotspot from vdistance

Hi,

I have a room where you need to investigate using a candle, and I don't want the player to be able to click on any hotspots that are not in the range of the candles glow. But once the lamps have all been turned on they can be accessed from any range. Is there a way to toggle this on and off, plus to toggle an amount of hotspot off and on too? Can i do this with a label and a script?

Thanks!

Comments

  • If you make use of "Player Vicinity" Hotspot detection, then Hotspots will only be interactive if within the boundary of a given collider. You could attach such a collider to the candle in your Player's hierarchy to have the candle's position affect which Hotspots are interactive.

    See the Manual's "Player-vicinity detection" chapter for details on this.

    The Settings Manager's Hotspot detection method can be changed through script with:

    AC.KickStarter.settingsManager.hotspotDetection
    

    Focus on getting your Player set up to work with "Player Vicinity", and only then look into having the above field change to Mouse Over / Player Vicinity at the correct time.

  • Thanks, following guidance but stuck here:

    "Finally go back to your Player's Inspector and assign this new GameObject as the
    Hotspot detector child."

    Assign it to where?

  • In the "Hotspot detector" field in your Player Inspector.

    This field will only be visible if you're making use of Player Vicinity detection.

  • So, and forgive me again, how would i add the:

    AC.KickStarter.settingsManager.hotspotDetection

    to a script? Thanks!

  • You can place it inside a public function inside a custom script:

    using UnityEngine;
    using AC;
    
    public class SetHotspotDetection : MonoBehaviour
    {
    
        public void SetMouseOver ()
        {
            KickStarter.settingsManager.hotspotDetection = HotspotDetection.MouseOver;
        }
    
        public void SetPlayerVicinity ()
        {
            KickStarter.settingsManager.hotspotDetection = HotspotDetection.PlayerVicinity;
        }
    
    }
    

    To change the hotspot detection, you can then call this script's SetMouseOver and SetPlayerVicinity functions when appropriate - either using the Object: Send message or Object: Call event Actions.

  • So would I attach this to a scene game object or create a custom action script from this script?
  • edited November 2021

    No custom Actions - again, you can use the Object: Send message or Object: Call event Actions to call the script functions.

    Attach to a GameObject. It needn't be in the scene - make it a prefab and you can call the functions from any scene.

  • So, followed instructions, and it seems that:

    A: I can't affect the SetPlayerVicinity event and

    B: Parameters cannot be set

    See screenshot

    https://www.dropbox.com/s/96hwlougutjkbzf/PlayerVicinity.png?dl=0

  • The functions have no parameters to set.

    The Action must also reference the component on a GameObject/prefab - not the script asset directly.

  • edited November 2021
    Ah I got it I think. So set mouse over for non vicinity scenes and set hotspot detect for vicinity scene?
  • Would it be possible to amend script so that you could set the vicinity distance when turns on too?

  • The vicinity distance is determined by the size of the Hotspot Detector's Trigger. This can be set through script (e.g. Radius if its a Circle Collider 2D), or through animation.

  • edited November 2021

    ok thanks

  • Would you be able to show me through script how to resize radius? Would be much appreciated. That way I never have it change between mouse over and hotspot vicinity

  • It depends on what collider type you're using for your detector, and how many discrete values you want it to have.

    A non-script approach would be to animate it - i.e. attach an Animator to the collider, create animations for each of the values you want it to have, and then control playback with the Object: Animate Action. This technique would also allow you to make use of the Remember Animator component to save its state.

  • Ok thanks Chris I’ll give it a whirl!
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.