Download

Help with Arrays

I’ve made a basic button that I want to use throughout my level.
When activated it changes a boolean variable in a gameinstance blueprint called “ButtonStatus”
This variable is then accessed by the door/platform/object and the desired effect occurs.
The problem I then have is that all the buttons will activate all the effected objects.
From reading up it seems that making the variable an array can help with this, a separate value for each button.
How would I get it so that when the button BP is placed it creates an extra value in the array?
Any other advice on what the best way of doing this would be?

Array Add?

Alright, so there are several ways to go about this, but it is entirely situational (depends on how your objects are set up).

I think your best bet is to make a button with a variable called ID, and the door or platform you want to activate should also have a variable called ID.

In this way, when you press the button, it iterates through the actors in your level until it finds one with a matching variable ID.

You could make a base class called button, and a base class called item maybe, and put that variable there, and then have your buttons and items inherit from those classes.

You will want a function called ItemActivate on your base item class, that you can override.

There are several approaches, and there are much easier ones than this, but it depends on what you are setting up.