Forum rules - please read before posting.

is it possible to change value of Slider (in menu) via Action List?

edited September 2024 in Technical Q&A

Hello, I have a question that I can't figure out myself, the point is that I have a character whose energy increases with increasing level, I set it all up through the Slider, but I can't figure out how to increase the slider value through Action List, I need change 100 to 120. So far I only see the option of creating a new menu (menu number two, three, etc.), but I wouldn't want that
https://simp6.jpg5.su/images3/Screenshot_28ec8595aeea57de7.png

Comments

  • Welcome to the community, @zombiegruppe.

    Are you looking to change the Slider's "Max value" field?

    You'll need to use a custom script for that. This function should do it:

    public void UpdateMaxEnergy ()
    {
        int myNewValue = AC.GlobalVariables.GetVariable ("MaxEnergy").IntegerValue;
        (AC.PlayerMenus.GetElementWithName ("MyMenu", "EnergyBar") as AC.MenuSlider).maxValue = myNewValue;
        AC.PlayerMenus.GetMenuWithName ("MyMenu").Recalculate ();
    }
    

    Replace MyMenu with the name of your Menu, and create a Global Integer variable named MaxEnergy, that represents the max value (e.g. 100 by default).

    To run this function, paste into a C# script, add to a GameObject, make that a prefab and remove from the scene. Then use the Engine: Call event Action to run this prefab's UpdateMaxEnergy function.

  • Thank you very much Chris, you helped me a lot and reduced the time it took to create additional menus, I'm just starting to create my own game, but I really like your product!

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.