2023-11-15 15:19:40 +11:00
|
|
|
extends Weapon
|
|
|
|
class_name ProjectileWeapon
|
|
|
|
|
|
|
|
@export var projectile_scene : PackedScene
|
|
|
|
|
2023-11-16 00:07:41 +11:00
|
|
|
var force := 20.0
|
2023-11-15 15:19:40 +11:00
|
|
|
var projectile_id := 0
|
|
|
|
|
|
|
|
|
|
|
|
func shoot():
|
|
|
|
super.shoot()
|
2023-11-16 00:07:41 +11:00
|
|
|
networked_spawn_projectile.rpc(multiplayer.get_unique_id(), -global_transform.basis.z)
|
|
|
|
|
|
|
|
|
|
|
|
@rpc("reliable")
|
|
|
|
func networked_shoot():
|
|
|
|
super.networked_shoot()
|
|
|
|
|
|
|
|
|
|
|
|
@rpc("reliable", "call_local")
|
|
|
|
func networked_spawn_projectile(peer_id, direction):
|
2023-11-15 15:19:40 +11:00
|
|
|
var projectile = projectile_scene.instantiate() as Projectile
|
|
|
|
projectile.position = global_position
|
|
|
|
projectile.damage = damage
|
2023-11-16 00:07:41 +11:00
|
|
|
projectile.direction = direction
|
2023-11-15 15:19:40 +11:00
|
|
|
projectile.force = force
|
2023-11-17 20:49:38 +11:00
|
|
|
projectile.owner_id = peer_id
|
2023-11-16 00:07:41 +11:00
|
|
|
projectile.name = str(peer_id) + str(projectile_id)
|
2023-11-15 15:19:40 +11:00
|
|
|
get_tree().root.add_child(projectile)
|
|
|
|
projectile_id += 1
|