Forum rules - please read before posting.

First Person - Trigger Actionlist on Cursor Hover?

Hi there,

I'm interested in Triggering events automatically via just looking at a trigger/hotspot, rather than via collision or clicking.
Is this possible via custom scripting?

Thanks for the help,
Max

V74
Unity 2020

Comments

  • edited June 2022

    You can hook into the OnHotspotSelect custom event - fired when a Hotspot is hovered-over - and either run a specific ActionList (by invoking its Interact function) or trigger that Hotspot's Interaction by invoking RunUseInteraction.

    Here's an example that does the latter. To prevent Hotspots from being interacted with normally (i.e. clicking), set your Interation method to Custom Script.

    using UnityEngine;
    using AC;
    
    public class InteractionOnSelect : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnHotspotSelect += OnHotspotSelect; }
        private void OnDisable () { EventManager.OnHotspotSelect -= OnHotspotSelect; }
    
        private void OnHotspotSelect (Hotspot hotspot)
        {
            hotspot.RunUseInteraction ();
        }
    
    }
    

    For more on scripting custom interaction behaviours, see the Manual's "Custom interation systems" and "Interaction scripting" chapters.

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.