Forum rules - please read before posting.

Need help with highlight component

Hi,
I've been reading up on the documentation about the Highlight component but I'm having some difficulty implementing it (I'm using AC 1.70.4 and Unity 2019.1.10f1).

What I'm trying to do it trigger FlashHotspots when the player left-clicks and holds anywhere on the screen that's not already causing an interaction (as opposed to the default "tab" key which does not work for touch screen controls). I'm encountering the following difficulties::.

  1. Many of my hotspots don't have a sprite attached to them (ie. exits, objects that can't be picked up, etc.) so I want to simply trigger a small sprite overlayed on top of each of those objects whenever FlashHotspots is called. The problem is I don't want that sprite to be visible by default; I only want it to appear when I hold left-click. At present, if I put a sprite on the scene and attach the highlight component to it, it is always seen -- albeit the brighten affect does work when I press "tab." At this point, I'm thinking I'm doing something fundamentally wrong?

  2. I'm able to invoke FlashHotspots by using the default "tab" key. But how can I make it so that it is triggered on holding left-click as well? Can this be done in the Input Manager?

Thanks!

Comments

  • A script to highlight hotspots while an input is held down, rather than single-pressed, can be found on the AC wiki.

    As for the effect itself, you can attach a simple script to the SpriteRenderer + Highlight component that updates the color of the Sprite manually, i.e.:

    using UnityEngine;
    using AC;
    
    public class SpriteHighlight : MonoBehaviour
    {
    
        private void Update ()
        {
            GetComponent <SpriteRenderer>().color = new Color (1f, 1f, 1f, GetComponent <Highlight>().GetHighlightAlpha ());
        }
    
    }
    

    You'll need to uncheck Auto-brighten materials when enabled? in the Highlight's Inspector too, so that it doesn't also affect the sprite.

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.