extends Area3D signal exploded @export var muzzle_velocity = 100 # How fast the bullets are @export var g = Vector3.DOWN * 5 @onready var bulletAuthority = get_multiplayer_authority() var velocity = Vector3.ZERO ###### CHEATS var godmode = 0 func _ready(): name = str("bullet ", bulletAuthority, "-0") func _physics_process(delta): velocity += g * delta # Bullet gravity look_at(transform.origin + velocity.normalized(), Vector3.UP) transform.origin += velocity * delta if is_multiplayer_authority(): for body in get_overlapping_bodies(): if body.get_path() == Global.selfTeddy: # We need to modify this to make the player not invinsible pass elif body.is_in_group("human"): var playerShot = body.get_multiplayer_authority() print("Bullet hit ", playerShot) #rpc("damage_player", playerShot) rpc_id(playerShot,"take_damage") self.queue_free() elif body.is_in_group("AI"): print("Bullet hit an AI player") body.queue_free() self.queue_free() else: print("Bullet hit something else") self.queue_free() await get_tree().create_timer(2).timeout self.queue_free() func _on_Shell_body_entered(body): emit_signal("exploded", transform.origin) queue_free() @rpc("any_peer", "call_remote", "reliable") 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 pass # Might use this later, or maybe not, we'll see @rpc("any_peer", "call_remote") func take_damage(): Global.playerHealth = Global.playerHealth - 10