Forum rules - please read before posting.

AUTO-DETECT HOTSPOTS

edited January 2023 in Technical Q&A

I am using 2d demo. Completed this tutorial https://adventurecreator.org/tutorials/setting-player-auto-detect-hotspots it seems to work well, when the player approaches the object, the name comes out on the cursor (I don’t know why on the cursor and not on the object).
But I changed the method to touch screen and the names appear with the mouse when I hover over the object. But how to set it up so that the player approaches and the name appears only on the object without the mouse..

Comments

  • The selected Hotspot's name is displayed inside the Hotspot menu, which can be found in the Menu Manager.

    By default, this Menu's Position property is set to Follow Cursor, causing it to appear over the cursor.

    To have it instead appear over the selected Hotspot, set this property to On Hotspot.

  • Hi Chris.
    I completely got rid of the mouse, but how can I make the icon above the object light up when an object approaches? I set everything up according to your lessons, with the mouse everything works when you hover over an object, but how to do it without a mouse. Thank you!

    https://ibb.co/QCcbb3N
    https://ibb.co/d4jB3CY
    https://ibb.co/Cvyv0vv
    https://ibb.co/JR5rgdR

  • Recreated - thanks for the details.

    It's a case of the behaviour being slightly different when using Touch Screen input.

    I'll see if this behaviour can be tweaked, but placing this script in your scene will allow for an icon to appear over the nearest Hotspot:

    using UnityEngine;
    using AC;
    
    public class ShowHotspotIcon : MonoBehaviour
    {
    
        public Texture2D icon;
        public float iconSize = 0.025f;
    
        void OnGUI ()
        {
            Hotspot nearestHotspot = KickStarter.player.hotspotDetector.NearestHotspot;
            if (nearestHotspot)
            {
                GUI.DrawTexture (AdvGame.GUIBox (nearestHotspot.GetIconScreenPosition (), iconSize), icon, ScaleMode.ScaleToFit, true, 0f);
            }
        }
    
    }
    
  • wow. thank you!
    Can you tell me where to put this script?

  • Add it as the new "Show Hotpsot Icon" component to any GameObject in the scene.

    In the meantime, I have looked into the issue further. Hotspot menus won't show up with your combination of settings, as it's set up to select a Hotspot and run an interaction with the same tap - but Hotspot icons / highlight effects should still show up.

    Though the script above can still be used, you should be able to use the "Hotspot icons" feature in the Settings Manager to display icons as you approach Hotspots.

    Currently you have Display Hotspot Icons set to Via Script Only, but if you set to Only When Highlighting, then they should appear when intended. Just be aware that Hotspots will also need to have a Highlight component assigned in their Object to highlight Inspectors - though this can be attached to the same Hotspot GameObject if you don't need a specific mesh/sprite to brighten with it.

  • I did: Add it as the new "Show Hotspot Icon" component to any GameObject in the scene. Everything seems to be fine. But what can be done so that you can add animation, and not a static picture and along the axis Y ? I will have like eyes (blink).
    I am adding a video showing how it works.
    https://drive.google.com/file/d/15KOEFI6UEZ97mHyW3Rv9hk0OelLuo1da/view?usp=sharing

  • AC's built-in Hotspot icon settings allow for animated icons.

    If you remove the script, set Display Hotspot Icons to Only When Highlighting, and then Hotspot icon type to Texture, you can then supply your texture in the field beneath.

    If this texture consists of multiple frames arranged in a grid, you can use the settings underneath to set the number of frames it has, which will play when the icon is shown.

    To have them display, you'll then just need to add a Highlight component to your Hotspot, and assign it in its Object to highlight field.

    By default, icons will appear in the centre of the Hotspot's collider. You can override this position, however, by assigning a separate GameObject (in the correct position) into the Hotspot component's Centre-point (override) field.

  • Thank you) all good)

  • Everything is fine. But how to remove a big step in animation? The texture goes over the edges. https://drive.google.com/file/d/1PewYe_nGP4V4D2We5iTP0wezdbbmwAWF/view?usp=sharing

  • When a texture is set to be animated, all frames of the animation must be part of the texture itself, arranged in a grid that matches the number of columns and rows you've set.

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.