I’ve followed numerous tutorials and watched several videos, however I’m having a lot of trouble adding basic network damage to the First Person Shooter template.
As of now I’ve changed the default weapon to a raycasting one and the damage seems to only apply from server to client, and the client cannot damage the server. I know that this is because the client doesn’t have the authority to run the commands necessary, but I’m at my wits end trying to figure out how to work around this.
Here’s what I have so far:
If anyone can help me out I’d really appreciate it, this is very frustrating.
Still have not found a solution, really could use some help.
Alright, so first off, I’m going to go ahead and say that I’m pretty new to networking/ replication myself, so don’t be surprised if what I say is wrong :).
So the first thing I see (which is totally irrelevant to your question, but not correct) is your custom event, “Do Damage”.
You call this event on this server, to call apply damage. Apply damage is already called on the server. Plus, since your already calling it on the server, you don’t need a “Switch Has Authority” node before or after you call apply damage. ← Hopefully that makes since.
So on to your question: In order for this to work, you need to call the line trace on the server. I don’t use raycasting to shoot my projectiles, so I’m not 100% if this is the correct way to do this or not. Let me know if it works out.
Also another tip to help you: When you test, check use dedicated server. That way, you can test effectively for all clients. When I was starting out, I didn’t use a dedicated server, and I would get confused as the server could do things the client couldn’t.
Hey, thanks for responding I really appreciate it.
The reason I had those “Switch Has Authority” nodes was just for extra protection (at least that’s what the guy who made Epic’s networking videos said), but I’ve removed them as I can see how they are redundant. Here is what “Do Damage” looks like now:
I tried moving the raycasting logic to it’s own function that’s called on the server, but that seems to not do anything (As in, it doesn’t even fire the raycast anymore - I’m assuming that I messed up somewhere along the line while transferring everything over):
I’ve set all functions to reliable.
Once again, thank you for taking the time to help out, I appreciate it
EDIT: Also, thanks for the dedicated server tip- that should make things a little easier when it comes to figuring out what works and what doesn’t.
THANK YOU! I can’t believe that I overlooked that. If anyone finds this in the future, here’s what I’ve ended up with:
There’s on small issue with the emitter not being spawned, but that should hopefully be a relatively easy fix! Thanks again!
Try passing your start and end vectors into the event on the server.
I’d assume its because it isn’t being replicated from the server to the clients, which shouldn’t be hard to fix.