Clients can hurt each other, server can't hurt clients and clients can't hurt server #3
This commit is contained in:
parent
028037cdc4
commit
2a729d85fa
2 changed files with 9 additions and 5 deletions
|
@ -23,7 +23,9 @@ func _physics_process(delta):
|
||||||
if body.get_path() == Global.selfTeddy: # We need to modify this to make the player not invinsible
|
if body.get_path() == Global.selfTeddy: # We need to modify this to make the player not invinsible
|
||||||
pass
|
pass
|
||||||
elif body.is_in_group("human"):
|
elif body.is_in_group("human"):
|
||||||
rpc("damage_player")
|
var playerShot = body.get_multiplayer_authority()
|
||||||
|
print("Bullet hit ", playerShot)
|
||||||
|
rpc("damage_player", playerShot)
|
||||||
elif body.is_in_group("AI"):
|
elif body.is_in_group("AI"):
|
||||||
print("Bullet hit an AI player")
|
print("Bullet hit an AI player")
|
||||||
body.queue_free()
|
body.queue_free()
|
||||||
|
@ -40,7 +42,10 @@ func _on_Shell_body_entered(body):
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
@rpc("any_peer", "call_remote", "reliable")
|
@rpc("any_peer", "call_remote", "reliable")
|
||||||
func damage_player():
|
func damage_player(playerDamaged): # This can be used later to make sure the server and all other peers know the health of all other players
|
||||||
print("A bullet hit me!")
|
rpc_id(playerDamaged,"take_damage")
|
||||||
Global.playerHealth = Global.playerHealth - 10
|
|
||||||
self.queue_free()
|
self.queue_free()
|
||||||
|
|
||||||
|
@rpc("any_peer", "call_remote")
|
||||||
|
func take_damage():
|
||||||
|
Global.playerHealth = Global.playerHealth - 10
|
||||||
|
|
|
@ -39,7 +39,6 @@ func add_newly_connected_player_character(new_peer_id):
|
||||||
|
|
||||||
|
|
||||||
func add_player_node(peer_id):
|
func add_player_node(peer_id):
|
||||||
print("Global teddy Authority: ", Global.teddyAuthorityID)
|
|
||||||
connected_peers.append(peer_id)
|
connected_peers.append(peer_id)
|
||||||
var player_character = preload("res://scenes/Teddy.tscn").instantiate()
|
var player_character = preload("res://scenes/Teddy.tscn").instantiate()
|
||||||
player_character.set_multiplayer_authority(peer_id)
|
player_character.set_multiplayer_authority(peer_id)
|
||||||
|
|
Loading…
Reference in a new issue