Forum rules - please read before posting.

Simple UI Button to Interact con Hotspot in 2D game

Hi!I have a little question, I want a button for my mobile game and when I press it, interact with the hotspot.

Now, I can do it with keyboard, but when I press the UI button, It's look like lose "focus" in the game and the button can't interact.

If I put some " Run actions" in Menu settings, everything work, but no when I try to make it interact with the hotspot.

My input method is Mouse and Keyboard and hotspot setting is player vicinity

Any way to do it easly? Thanks a lot

Comments

  • When building to mobile, you'll generally want to switch to the dedicated "Touch Screen" input method.

    However, "InteractionA" itself may have different results depending on context. Instead, it's better to rely on a custom script to specifically interact with the currently-active Hotspot.

    Rather than hooking up the UI Button to AC's Menu Manager, attach this script to it and have its OnClick event trigger the Interact function instead:

    using UnityEngine;
    
    public class UseHotspotButton : MonoBehaviour
    {
    
        public void Interact ()
        {
            AC.Hotspot hotspot = AC.KickStarter.playerInteraction.GetActiveHotspot ();
            if (hotspot) hotspot.RunUseInteraction ();
        }
    
    }
    
  • It work! Thanks! very simple solution and I like how it work!

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.