Forum rules - please read before posting.

hotspot detect (gather mode) "is in screen"

Any suggestions on this? Using the hotspot detector I'm trying to have it detect everything in view of the camera screen rather than using the collider on player. I'm thinking I would use the hotspot detector (gather mode) as a "custom script" but I've had no luck with what to do in that custom script. So every enabled hotspot in screen is detected is my end goal.

I considered having a collider x,y stretch and rotate to x.y size of screen and the z just be super long or something but that seems kind of a kooky way to go about it.

With (gather mode) on "trigger detect" and having collider on player everything works as you'd expect.

Maybe I just need a custom script in the hotspot detection method in settings?
Any direction would be greatly appreciated.

Unity Version 2021.3.16f1
AC Version 1.78.4

Comments

  • edited November 2023

    I've wanted this too sometime ago, and found this code on the forum, is this is what you're looking for?:

    https://adventurecreator.org/forum/discussion/12233/showing-a-quest-marker-on-hotspot

    using UnityEngine;
    using AC;
    
    public class ShowNearbyHotspotIcons : MonoBehaviour
    {
    
        public float maxDistanceFromCamera = 20f;
    
        private void Update ()
        {
            foreach (Hotspot hotspot in KickStarter.stateHandler.Hotspots)
            {
                float distanceFromCamera = (hotspot.GetIconPosition () - Camera.main.transform.position).sqrMagnitude;
                bool isCloseEnough = distanceFromCamera < maxDistanceFromCamera;
                hotspot.SetIconVisibility (isCloseEnough);
            }
        }
    
    }
    

    Just add it to an empty GameObject to every Scene you want this to be in, and adjust the maxDistance according to your liking.

    And set the option Hotspot Settings: Display Hotspot Icons to via script only.

    You can adjust the Hotspot Icons on every Hotspot with the centre-point override on the Hotspot Component of the Object.

  • So to clarify why I'm doing this.

    It's so when I use a controller I have left and right trigger cycling through the "detected hotspots". The only one with the icon will be the one highlighted/selected. Which I have all working. But I need that "detected hotspots" list to be only what's in screen.

    I only want to cycle through the ones on screen not the further away ones say for a parallaxing scene. So instead of using the collider on player adding hotspots to that list. I need somehow to add/subtract what is and isn't on screen.

  • Another thought would be to use the "hotspot detector" collider on player method and making the collider massive so all hotspots are added to the list and then removing the ones not in view of camera..? IDK I'm at lose.

  • Sounds similar in style to the "Screen-space Hotspot detection" UI template available on the Downloads page.

    This template uses an invisible screen-space circle (with a distance check) to determine which Hotspots are interactive - inspired by the interaction system of Beyond A Steel Sky.

    It might be that you need to modify it further to suit your exact needs - but should be a decent starting-off point, from what you describe.

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.