Hello … i have a problem that i cant solve until now. for example i have a locked door and i want to be able to play the open animation of that door only when i collect 3 keys.
i know i must make some variables but i am lost can someone help me of how to do it?
Did you started pick up your keys ?
Is your door work fine ?
You can’t do something whithout trying to do something.
Explore Event Dispatchers.
The task is the following if the keys are unique.
Key Blueprint:
- Create an Event Dispatcher on the Key called OnPickedUp and add an Input of type Key object reference to it
- Create a Custom Event and call it PickedUp and have it call the Event Dispatcher and give it the reference to Self.
Door Blueprint
- Create an instance editable Array of Key object reference and call it “KeyLocks”
- On BeginPlay make a ForLoop on the “KeyLocks” array and Assign to the Event Dispatcher OnPickedUp. The Auto generated Custom Event should be named something like “OnPickedUp_Event”.
- At the OnPickedUp_Event use the reference to Key and Remove it from the “KeyLocks” Array. Check if the Array Length equals 0 and if it does then call an OpenDoor Event.
Level Editor
- Find the individual Doors and assign the Keys to the Door “KeyLocks” array. Make sure there is no empty reference entries in the array.
Or more simple :
- Make an actor key with a trigger on overlap. when overlap it put player Nbkey var set +1 and destroy the key.
- On the door a trigger overlap count the Nbkey on the player overlaping : branch condition 3 : Open.