Forum rules - please read before posting.

Right click for interaction

Hello guys !

I have a movement method : point&click
I'm with "Choose hotspot then interaction"
I would like to make my interaction menu appears with a right click instead of a left click.

If i choose "see interactions" with "click on hotspot" interaction menu appears with a left click

If I add an input InteractionA with mouse button 1 in my input settings it works but it also affects the movement of my character (i cannot left click to make him move anymore)

I almost succeeded by making a "see interactions with" via script only and making a script... but it seems complicated to make a script only for that...

Am I missing something simple or scripting is the only way ?

Thanks for help ;)

Comments

  • It would require scripting, but shouldn't be complex. This should be possible just by overriding "InputGetButtonDown", so that when a request for InteractionA is made while the cursor is over a Hotspot, it instead requests InteractionB.

    See the Manual's "Remapping inputs" chapter for more on this technique, but this should do it:

    using UnityEngine;
    using AC;
    
    public class SwitchHotspotButton : MonoBehaviour
    {
    
        private void Start ()
        {
            KickStarter.playerInput.InputGetButtonDelegate = MyButtonDown;
        }
    
        private bool MyButtonDown (string axisName)
        {
            if (axisName == "InteractionA")
            {
                if (KickStarter.playerInteraction.GetActiveHotspot () != null && !KickStarter.playerMenus.IsInteractionMenuOn ())
                {
                    axisName = "InteractionB";
                }
            }
    
            try
            {
                return Input.GetButtonDown (axisName);
            }
            catch {}
    
            return false;
        }
    
    }
    
  • Thanks Chris for your answer, I understand the logic but i may be missing something (simple i guess) coz it's not working even with my comprehension of the manual and the tutorial on remapping controls in-game.

    I've added some debug to your code =>

        Debug.Log(axisName);
        axisName = "InteractionB";
        Debug.Log(axisName);
    

    When my mouse is over an hotspot i can see in the console "InteractionA" followed by "InteractionB" so the script seems to be well executed. But nothing happened when i make a right click... It stills work with a left click.

    I've tried to attach the script to an empty gameobject like in the tuto (even if the script is executed without that because i see the debug in console just after creating the script and launching the game), I tried to attach it to an hotspot but nothing happened.

    I'm still on "Choose hotspot Then Interaction" - "See Interaction with click on hotspot".

    Thanks a lot for your help and patience

  • Ah - sorry, you're using default mouse clicks, not InteractionA/B inputs.

    This script should specifically check for mouse clicks as opposed to generic buttons:

    using UnityEngine;
    using AC;
    
    public class SwitchHotspotButton : MonoBehaviour
    {
    
        private void Start ()
        {
            KickStarter.playerInput.InputGetMouseButtonDownDelegate = MyMouseButtonDown;
        }
    
        private bool MyMouseButtonDown (int button)
        {
            if (button == 0)
            {
                if (KickStarter.playerInteraction.GetActiveHotspot () != null && !KickStarter.playerMenus.IsInteractionMenuOn ())
                {
                    button = 1;
                }
            }
    
            try
            {
                return Input.GetMouseButtonDown (button);
            }
            catch {}
    
            return false;
        }
    
    }
    
  • Ok it works now ;) thanks Chris

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.