Hello everyone, I actualy have a really strange problem that I really can’t understand…
- My game is multiplayer, with one host player & the other player as a client.
- I have two BP :
The player BP
An object called “Torus”
—> When the player enter in the Torus, in order to use the effect of the Torus object, he have to press enter key. This will activate a boolean called "CanEnterTorus
------> The Torus check if the player boolean is “TRUE” & this variable is linked to a “Branch”
THE PROBLEM IS :
When a host player enter the “Torus” BP & press the key in order to launch the effect, the “Torus” doesn’t work properly… the player is teleported just a little, & just some of the effects are trigered
However, the Torus BP is working well for the host with this boolean
AND the Torus BP is working well for host & client without this boolean
-----------> BUT, I don’t understand why it’s not working, because when I use another boolean (the number 2 in the picture)…then it work…
Please tell me if more explenation are needed, I’m crazy about this problem that looks really absurd !!
I’m working on UE4.24.3
It seems a replication problem, but with your description and just the image you provided I cannot understand where’s the problem and what’s wrong with your BP.
Is the CanEnterTorus bool replicated? Why are you using “Launch1” NetMutlicast RPC? Where is this RPC called?
Hello @Scienziatogm thx a lot for your answer.
Actually CanEnterTorus bool is not replicated. However I’ve tried to replicate it and it doesn’t work.
I use “Launch1” NetMutlicast RPC in order to do some action on the player (like change material, rotate mesh, etc).
Actually RPC is directly called from the “Set Timer by Function Name”, however I’ve tried many & many things & different ways in order to make it work.
→ That’s why I’m trully lost, I don’t understand where is the problem…
It’s not an efficient way of replicating things. Don’t use RPC NetMutlicast, especially Reliable NetMulticast if you can avoid them. OnComponentBeginOverlap will be triggered on the server when an actor hits your capsule, so (1) is not needed and it can make security issues if a bad client calls this server RPC with external tools, so you can delete that.
(2) This should be just a function, but not an RPC, and since you used Switch Has Authority before, you know that this function will be executed only on server. Now use Replicated Variables w/ RepNotify instead of NetMulticast RPCs! I don’t know what you’re trying to achieve, but if you are the server and you set a Replicated Variable to another value, the new value will be sent to all clients, and with RepNotify you can do what you want when this value is changed, for example you can change a PointLight color or, I don’t know, make all players jump , it depends on you.
This is the most efficient way to replicate things relevant for the gameplay without making a huge lag.
I hope I was clear, I’m not very good at explaining things so if you have any questions, feel free to ask!
Again, thanks a lot @Scienziatogm for your time & help !
What I’m trying to achieve is to make the player rotate, change material, and some other Stuff. I want this to be visible by the player & also other players.
→ However, I can’t use RepNotify function because some BP are not taken into account in the function… (like timelines for exemple)…
Timelines have a tick to set them as replicated, so you can call them on server and their values will be replicated. Here you can find more infos about RepNotify: 1.4 - Variable Replication [RepNotify] | Unreal Engine Documentation
Yes that’s right haha, thank you again
Wanted to bump this again. If i may ask… i do a similar System Host and 3 Clients max. I use Rpc (Customevent Sever - Custom Event Multicast - Customevent to actual Nodes which also sets Booleans ect. Its wierd its really unreliable (yes i checked reliable) it also dont fire sometimes the BOOLEAN if i play the Game as Host….
So are Booleans Sets after a RCP always a dumb idea? I call often probably 10 nodes after a RCP…. What could be a solid practice for this? Can i set a Boolean to replicated with RepNotify on also after an rcp, or is it wrong too?
you should call Server RPCs only if you are not the host (you don’t have authority), and keep in mind the security aspect of calling a Server RPC (even if it doesn’t seem so important, but I assure you that it is): everyone can call Server RPCs using hacks, so you should check their value on the server and use them only if they are necessary.
For example, some character movement code uses Unrealiable Server RPCs for example, because it gets called every frame if I remember correctly.
Where does your Server RPC get called? If you call an RPC every frame for example, don’t set it reliable, because it will flood the connection instantly.
If I understood correctly you have this setup: Client calls a Server RPC → Server RPC calls a Multicast RPC → Multicast RPC executes the code for everyone. I would avoid this type of approach, instead I would do the server logic only on server and the client logic on clients, avoiding multicast RPCs if possible. I don’t know your actual code, so I don’t know how you can fix your setup.
Regarding your last question, you can’t assure the order of RPCs or RepNotifies, so that’s a bad practice.
Anyway if you can post some screenshots of your RPCs maybe I’ll understand better the situation.