How would I add a kill counter in my game that’s multiplayer , Right now it shows at the screen of the player that was killed
it does this
@rpc("any_peer")
func receive_damage():
health -= 1
if health <= 0:
health = 3
position = Vector3.ZERO
kill_count.text = "Kill count = " + str(score)
health_changed.emit(health)
I found a another thread which I think it uses it,
however I’m getting an error
res://Player.gd:108 - Parse Error: Expected opening “(” after function name.
Here’s the code
@rpc("any_peer")
func Player.receive_damage.rpc(self):
health -= 1
if health <= 0:
health = 3
position = Vector3.ZERO
kill_count.text = "Kill count = " + str(score)
health_changed.emit(health)
@rpc("any_peer")
func Player.receive_damage.rpc(self)
health -= 1
if health <= 0:
health = 3
position = Vector3.ZERO
kill_count.text = "Kill count = " + str(score)
health_changed.emit(health)
Your code below it should not be indented if the func line was not the function itself. If it is supposed to be that then it should look like func Player.receive_damage.rpc(self): and you should use the self “variable” or just delete it in case it gives you any popups.
Also I think it might not work if the function is labeled weirdly like that
I’m not 100% sure what your asking but if your asking on how you could get the player that killed the player then you could add a “variable” to the “player damage” function like:
func playerDamage(Player, Damage):
So when you call it you put the player and the damage in the function so it’s easy to work from there as you would have the killer/last person to damage.