#I m making a MOBA game and ran into a
1 messages · Page 1 of 1 (latest)
Alright so this is due to server client delay, your issue is that you
1 check on the client if they can attack
2 they request the server to attack
3 server confirms that the attack was successful
4 attackTimer is being set
There's a delay from 2-4 because it is being send over the network
and thus if another update on your cleint happens between 2-4 it'll send another server RPC
and since you don't check on the server if the unit has recently attacked, it will just say "yeah cool let me spawn a bunch of projectiles"
so you get 3-4 projectiles (depending on your ping to the server) Then it waits the attack timer out and then another 3-4 projectiles
You can fix this by setting the attack timer when you send the server RPC
But again, you should also check the attack timer inside the server RPC itself, that way this would have never been a problem in the first place
Got it?
(I now see that you did in fact post the code, missed that my bad!)
@graceful fractal
im here and i'll try this
so, i need set attackTimer on ServerRpc?
i having this error in host console when client is attacking
https://pastebin.com/ytD0hRbr
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Update code?
That error is from a different class that you send
@graceful fractal
Yes - you can keep the update as is with it decreasing the attacktimer if it is above 0 - it is ran on both the server and the client
you then set the attack timer on the client to prevent it from spamming the server, and you set the attack timer in the serverrpc to avoid cheating
Alright same class but need updated code