Godot Version
4.3
Question
Hi I’m new on the forums so sorry if this is the wrong place, but I need help with this. I’m working on a fps and when ever I shoot its doing some real weird stuff. So when ever the “Host” player shoots another player nothing happens (not good) and if 2 non host players shoot each other nothing happens but if any other player shoots the host he takes the damage
I have no idea how this forum stuff works so I don’t know if i need like anything special in the post but uh heres the code for calling out a hit:
if Input.is_action_pressed("fire"):
# second shotgun
if guntype == 6:
if shot_2load > 0 && shot_02am.is_playing() == false:
shot_2load = shot_2load-1
hud.rounds = shot_2load
shot_02am.queue("fire")
if self.is_in_group("Team 1") == true:
for r in shot_02cast.get_children():
if r.is_colliding():
if r.get_collider().is_in_group("Team 2"):
r.get_collider().shot2hit.rpc_id(r.get_collider().get_multiplayer_authority())
print("a player was shot")
if self.is_in_group("Team 2") == true:
for r in shot_02cast.get_children():
if r.is_colliding():
if r.get_collider().is_in_group("Team 1"):
r.get_collider().shot2hit.rpc_id(r.get_collider().get_multiplayer_authority())
print("a player was shot")
this is the shot function
@rpc("any_peer")
func shot2hit():
var qty = 6
subtracthealth(qty)
the part that subtracts health and respawns you
func subtracthealth(qty):
if $MultiplayerSynchronizer.get_multiplayer_authority() == multiplayer.get_unique_id():
health = health - qty
hud.health = health
if health <= 0:
hud.health = 0
$Timer.start
func _on_timer_timeout() -> void:
respawn()
func respawn():
if $MultiplayerSynchronizer.get_multiplayer_authority() == multiplayer.get_unique_id():
global_position = spawnpoint.global_position
health = 100
shotammo = 6
shot_2load = 2
guntype = 55
Any help would be greatly appreciated :)