godot-demo-projects/networking/multiplayer_bomber/bomb.gd

24 lines
496 B
GDScript3
Raw Normal View History

extends Area2D
var in_area = []
var from_player
# Called from the animation
func explode():
2018-03-14 05:52:41 +01:00
if not is_network_master():
# But will call explosion only on master
return
for p in in_area:
2018-03-14 05:52:41 +01:00
if p.has_method("exploded"):
p.rpc("exploded", from_player) # Exploded has a master keyword, so it will only be received by the master
func done():
queue_free()
func _on_bomb_body_enter(body):
2018-03-14 05:52:41 +01:00
if not body in in_area:
in_area.append(body)
func _on_bomb_body_exit(body):
in_area.erase(body)