Understanding Triggers for Multiplayer
SO, what I am trying to achieve is having 2( or more ) characters enter a trigger box and the doors opens. Simple. When one character leaves the Trigger, the door should remain open and when all characters leave the trigger box, then all the doors can close.
Now, in single player this works perfect for obvious reasons. I have a OnComponentBeginOverlap and a OnComponentEndOverlap triggering actions. Player leaves, the door closes.
My multiplayer set up is roughly the same except, I made Custom Events and turned on Multicast. so when someone enters the trigger area, it triggers a boolean(set to replicate) thru the multicast custom event. (Here I'm still trying to understand when to use Replicators and Switch Has Authority nodes)
My problem is when all the characters are in the trigger box and one character leaves, the door shuts.
I know I'm missing something/s. Can anyone direct me to how I should set this up? I feel it will shed some light on alot of things I might be doing wrong or don't understand.
Btw I'm new to coding for multiplayer on UE4.
Thanx in advance.
asked Jul 12 '16 at 09:45 PM in Blueprint Scripting
Make sure you add Switch has authority after begin/end overlap before using multicast event, and then make sure your variable IsGate has replication changed from none to replicated
answered Aug 10 '18 at 09:51 AM
So the problem is that your current code means that whenever a character leaves, it triggers the door closing. You want it to remain open until everybody is gone. What you may want to do is assign an array to the door. On Begin Overlap the character adds himself to the array, and when a character leaves, they remove themselves from the array. Then instead of a boolean you use the length of the array. If the array is empty, it closes, if it has one or more items in it, it opens.
answered Mar 20 '19 at 06:33 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here