Forum rules - please read before posting.

Create a puzzle rpg game

Hello, everybody,

I am creating a horror puzzle rpg game, like japanese rpg game: Ib. I only want the player to use the keyboard, therefore, I have set the following configurations: The movement method that I use is Direct, the input method is Keyboard Or Controller and the interaction method set with Context Sensitive. I have several questions:

1) I want to create a keypad lock, I read some related forum, so I made a menu that has different buttons with their numbers. In the actionlist of door hospots, I changed the state to turn on of that keypad menu, the problem is that although the menu appears on the screen, if I move with the keyboard movement control, the player moves, but I can't navigate the menu buttons with keyboard. I want when the menu appears on the screen, instead of moving the player, navigate through the menu.

2) Another function that I want to do is waiting until variable change using OnVariableChange custom event. I don't want loop ActionList.

3) ¿Is there any way to call and run specific interactions with the code?

I don't know the coding so much, does anyone give me a sample script I will appreciate it.
Sorry about my english.

Best regards,
Lrei

Comments

  • Welcome to the community, @Lrei.

    I want when the menu appears on the screen, instead of moving the player, navigate through the menu.

    See the Manual's "Navigating menus directly" chapter for details on how to navigate menus using the keyboard.

    The easiest way to do this is to check Pause when enabled? in the Menu's properties, so that the game (and Player character) freezes until the Menu closes again. If you then also check Directly navigate menus when paused? at the top of the Menu Manager, the menu will be navigable with the keyboard.

    If you instead want the game to continue running in the background, you'll have to use the Engine: Manage systems Action to both disable the Movement system (so that the Player cannot move), and also enable the direct-navigation of in-game menus.

    Another function that I want to do is waiting until variable change using OnVariableChange custom event. I don't want loop ActionList.

    The OnVariableChange event passes the changed variable as a parameter. You can read this variable's label property, and e.g. run an ActionList, if it matches the name of the variable you want to listen out for.

    Example code:

    using UnityEngine;
    using AC;
    
    public class VariableChangeExample : MonoBehaviour
    {
    
        public ActionList actionList;
    
        private void OnEnable () { EventManager.OnVariableChange += OnVariableChange; }
        private void OnDisable () { EventManager.OnVariableChange -= OnVariableChange; }
    
        private void OnVariableChange (GVar variable)
        {
            if (variable.label == "MyVariable")
            {
                actionList.Interact ();
            }
        }
    }
    

    ¿Is there any way to call and run specific interactions with the code?

    See the Manual's "Interaction scripting" chapter. Any ActionList, and ActionList asset file, can be run by invoking its Interact function - see the example code above.

    If you can share more detail on exactly what kind of interaction you wish to call, and when, I can try to provide a more specific answer.

  • Thank you, Chris!

    About running interactions with code, the example code is what I want to do temporarily. But I have a problem with that code, Is that code only works with variable changes in AC actionlist? The code doesn't work with variable changes in custom script. I have variable changes when two objects have collision in my custom script. Is there any way to solve it?

    Besides, I have another question about the menu. Is there any way to use a custom script that handles the actions of all menu buttons of my keypad lock menu? Because the button's action lists are very similar and I want to do it in a single script. For example, when I open the menu, I want that when I press button 1, the variable changes to 1, when I press the OK button it verifies the password and when I press the exit button, it closes the menu.

  • Is that code only works with variable changes in AC actionlist? The code doesn't work with variable changes in custom script.

    AC can only detect changes made to AC variables - though AC variables can also be set through script.

    You can either update your custom script to simply run the ActionList asset manually at the same time you change one of your script variables, or replace the script's variables with AC variables.

    For example, if you have an AC Global Integer variable named "MyInt", you can set its value with the command:

    AC.GlobalVariables.GetVariable ("MyInt").IntegerValue = 123;
    

    Doing so will also trigger the OnVariableChange custom event in the above script.

    Is there any way to use a custom script that handles the actions of all menu buttons of my keypad lock menu?

    Yes, you can hook into the OnMenuElementClick event to script the behaviour of a button:

    using UnityEngine;
    using AC;
    
    public class KeypadButtonProcessor : MonoBehaviour
    {
    
        void OnEnable () { EventManager.OnMenuElementClick += OnMenuElementClick; }
        void OnDisable () { EventManager.OnMenuElementClick -= OnMenuElementClick; }
    
        void OnMenuElementClick (AC.Menu menu, MenuElement element, int _slot, int buttonPressed)
        {
            if (menu.title == "Keypad" && element.title == "Button1")
            {
                // Clicked element named "Button1" inside menu named "Keypad"
            }
            else if (menu.title == "Keypad" && element.title == "Button2")
            {
                // Clicked element named "Button2" inside menu named "Keypad"
            }
        }
    
    }
    

    Alternatively, you can look into using paramaters in your ActionLists. Parameters allow you to "recycle" ActionLists that perform common tasks, by altering the field values in its Actions.

    For example, you could have an ActionList named "OnClickKeypadButton", that has an Integer parameter to represent which button was pressed, and then use that parameter to process the state of the entered code.

    A tutorial on parameters can be found here.

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.