I have a flashlight actor that’s attached to the player. The flashlight actor has a Toggle function. When called, the flashlight should turn off.
The flashlight function works in single player, but in multiplayer it doesn’t. I’m using function replication to request the server to turn off the flashlight. The event is being called, and so is the toggle function from the flashlight, but it’s not turning off in-game.
Player BP:
Flashlight BP:
This leads me to believe I’m missing a checkbox in the editor, or the “Toggle Visibility” node doesn’t work in multiplayer, because the toggle function is being called on server. Because it works in single player. Replication is checked for the Flashlight actor.
If it means anything: The flashlight rotates with the actor on the owner’s screen, but it doesn’t rotate on other clients (it rotates horizontally but not vertically). I’d also like to fix that.
Yes toggle visibility is probably something local and should stay like that because it’s something “aesthetic”, not really affects the game play mechanics. If you want this behavior to replicate to everybody then you should make a new Custom Event that is set to Multicast and ToggleFlashLight should call it right after the authority check.
Hmm, it’s not working. Am I supposed to do it like this?
As to why all clients need to be notified if someone else’s flashlight is on: my game is is completely in dark, so having a flashlight on could give up your position. So it’s really important that if a client has a flashlight on it’s visible to other (potental enemy) players.
Edit: Oops, I found my mistake. Off of Multicast Toggle FlashLight (where my cursor is) I shouldn’t have been checking for authority. When I deleted it, it worked.