Hi fellow forum members,
I was trying to replicate a raycast but, it seems to be not working as I expected.
Please have a look at my script first:
“ServerInitializeAttack” is currently set to “Run on Server/ Reliable” while “InitializeAttack” is set to “Multicast/ Reliable” which runs “Attack” function.
On Server side, the raycast spawned by Client side is not spawned on the direction or location that client is currently looking at but spawned on the direction or location that server is looking at, and it’s same for vice versa.
Here’s the video that I captued:
Could anyone please advice me on how I could fix this problem?
If your problem is that everytime a player Fires it calls the Initialize Attack what is causing it is the multicast, which replicates the same event call to everyone. Once you call a chain of events/functions on the server (Run on server), it will update to every client that this player has called those events/functions itself, but with multicast you will make them all to call those events themselves, it’s like one universal input for every client to start firing.
Try removing the multicast on your chain of events to safely not trigger them in every client.
Add a “Switch has Authority” after the Input Fire; in the remote node, you’ll call the Event “Server Initialize Attack”(Run on Server). In the “Authority” node you will call the “Initialize Attack”, which you must change it to “Not Replicated” once you are already replicating it as a server (Authority).
Try those changes and this might solve this problem
Did you mean by something like this?
If so, unfortunately, this doesn’t seem to be working
I have also changed “InitializeAttack” to not replicate.
What is happening now? Describe the Client and the Server behaviors after those changes.
Server still draws Client’s raycast on Server’s point of view while Client does not draw either of them (raycast spawned by itself as well as Server one).
ok, after server initialize attack, connect the initialize attack event. That will show the raycast in the client window.
Try changing inside the “Attack” function, where it shows "Get player Camera Manager->Player index ‘0’ " change as the pic:
I think what is causing you to draw the Client Fire in the server window is because the Player Camera Manager Index ‘0’ will always get reference from the server (Server may be the Player index ‘0’), so all the vectors will be get from the Server, resulting it to draw the line always from the Server camera Manager.