Forum rules - please read before posting.

Add Input Action to cycle interactions backwards

Hi!

I want to create the following behaviour:

  • When a user presses A button on the joystick, the interactions cycle (look, use, talk) -> I already have this implemented.
  • When a user presses B button on the joystick, the interactions cycle backwards (talk, use, look) -> I have problems getting this to work.

The idea is allowing the user to browse the available interactions using two buttons.

I have already created a new Active Input using the Action Inputs Editor and created a new one named "InteractionC (Button)" and I have already created a new action list to be triggered but I don't know what actions to execute there to cycle the interactions backwards.

Could you give me some clues?

Thanks in advance!

Comments

  • An Active Input shouldn't be necessary, depending on your settings. Check the "Available inputs" panel in the Settings Manager - are CycleInteractionsLeft / CycleInteractionsRight listed? If so, mapping inputs to these names should allow for this.

    If not, share your Interface settings so that I can see how your game is controlled.

  • Hi Chris!

    Thank you for your quick answer!

    Here's a picture of my available inputs:

    And my Interface Settings:

    Thank you again!

  • What is your AC version? "CycleCursorsBack" should be listed as an available input.

  • My AC version is 1.70.2.
    Is there a way I could manually add it?

  • I've been doing a quick research and I've found that, on the SettingsManager class I had:

    else if (interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
    {
        result = SmartAddInput (result, "CycleCursors (Button)");
    
        ...
    

    I've added result = SmartAddInput (result, "CycleCursorsBack (Button)"); there like this:

    else if (interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
    {
        result = SmartAddInput (result, "CycleCursors (Button)");
        result = SmartAddInput (result, "CycleCursorsBack (Button)");
    
        ...
    

    And now I see CycleCursorsBack listed on the Available inputs:

    I guess that this should do the trick, isn't it?

    Thank you!

  • Answering myself, yes and no.

    That step is needed but I'm missing something else, I'm researching more and I will post here my findings.

  • So finally I have it working.

    In PlayerCursor.cs I had:

    else if (KickStarter.stateHandler.IsInGameplay () && KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot && KickStarter.cursorManager != null &&
                        ((KickStarter.cursorManager.cycleCursors && KickStarter.playerInput.GetMouseState () == MouseState.RightClick) || KickStarter.playerInput.InputGetButtonDown ("CycleCursors")))
    {
        CycleCursors ();
    }
    

    And I have added an else if for the new CycleCursorsBack action:

    else if (KickStarter.stateHandler.IsInGameplay () && KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot && KickStarter.cursorManager != null &&
                        ((KickStarter.cursorManager.cycleCursors && KickStarter.playerInput.GetMouseState () == MouseState.RightClick) || KickStarter.playerInput.InputGetButtonDown ("CycleCursorsBack")))
    {
        CycleCursorsBack ();
    }
    

    I have also created a new CycleCursorsBack () function taking the existing CycleCursors () as model:

    protected void CycleCursorsBack ()
    {
        if (KickStarter.playerInteraction.GetActiveHotspot () != null && KickStarter.playerInteraction.GetActiveHotspot ().IsSingleInteraction ())
        {
            return;
        }
    
        int newSelectedCursor = selectedCursor;
    
        if (KickStarter.cursorManager.cursorIcons.Count > 0)
        {
            newSelectedCursor --;
    
            if (newSelectedCursor >= 0 && newSelectedCursor < KickStarter.cursorManager.cursorIcons.Count && KickStarter.cursorManager.cursorIcons [newSelectedCursor].dontCycle)
            {
                while (KickStarter.cursorManager.cursorIcons [newSelectedCursor].dontCycle)
                {
                    newSelectedCursor --;
    
                    if (newSelectedCursor < -1)
                    {
                        newSelectedCursor = -1;
                        break;
                    }
                }
            }
            else if (newSelectedCursor < -1)
            {
                newSelectedCursor = KickStarter.cursorManager.cursorIcons.Count - 1;
            }
        }
        else
        {
            // Pointer
            newSelectedCursor = -1;
        }
    
        SelectedCursor = newSelectedCursor;
    }
    

    And now everything is working as I wanted :smiley:

    I have to say that I had to go over all this process because I can't update to a newer AC version, so it's my fault.

    Also I have to say that I've been able to implement all this by myself because the Adventure Creator code is very straightforward and easy to understand!

    Thanks a lot for your help and for making such a wonderful asset, 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.