Hello, i am creating a box with password on it, and i faced a problem. When player types password, it sets isOpened bool variable to true to the whole class. However, i have 12 boxes with password, and i want it only to change value to one object player is interacting with. I know about Get All Actors of Class, but this doesn’t seem pretty comfortable.
“set over bp” - could you clarify how it works? The box is an actor with a widget component attached to it? If no, would it be OK if each box had its own widget component?
i attached password widget to bp with construction script, so yes. What do you mean each box had it owns. You mean i need to create other bp of widget component and then refer each one to bp?
A quick follow-up. Is there a reason why you’re using Construction Script rather than adding a widget component directly:
So what do you do in the CS? This?
Hello, i am creating a box with password on it […] When player types password, it sets isOpened bool variable to true to the whole class.
Do you store the correct answer / password in the widget or in the actor the widget is attached to? It’s unclear what happens where. What is whole class?
Essentially, we need more details to help you. Assuming I understood the setup, see if this makes sense:
call an event dispatcher in the Password Widget once you’ve determined the password was correct:
There is no reason for me to use cs, i just decided to do this way. By whole class i mean - it changes value to all objects on the scene.
I want to create suitcase with password, when player enters it, suitcase opens.
I have an array with passwords and when game starts bp takes random password index of array and sets it to bp box. Player enters it and everything works fine, but the problem is i have several bp objects on the scene and when password is valid, it sets bool var canBeOpened to all of the objects of class. I want bp to change value only to specific object player is interacting with. Sorry if i make too much headache to you.
What I suggested would be perfect for this. Actor + Widget Component. That’s all you need. Each suitcase has its own password widget.
Enter the password in the widget, if it’s correct, dispatch the message to the owning actor and that actor can do what it needs to (open the suitcase , I reckon). It will affect just this one actor.
i attached password widget to bp with construction script
We do not see it above, and I find it hard to imagine why you’d need to do this here. Are you, perhaps, mixing up Construction Script (actor) with the Event Construct (widget)?
You should never call Get (all) Actor of Class unless you know that you must. You do not need it here at all. Not entirely sure what SD is:
But this will never work if there’s more than 1 SD - read the tooltip of the Get Actor of Class to see what it does.