2023-11-15 15:19:40 +11:00
|
|
|
extends RigidBody3D
|
|
|
|
class_name Projectile
|
|
|
|
|
|
|
|
@export var collision_shape : CollisionShape3D
|
|
|
|
|
2023-11-17 20:49:38 +11:00
|
|
|
var damage_particle_scene = preload("res://Scenes/damage_particle.tscn")
|
|
|
|
var owner_id = 0 #should be left unchanged by towers, 1 for host, peer_id on peers
|
2023-11-15 15:19:40 +11:00
|
|
|
var direction := Vector3.FORWARD
|
|
|
|
var force := 2.0
|
|
|
|
var damage := 0.0
|
|
|
|
var lifetime := 10.0
|
|
|
|
var time_alive := 0.0
|
|
|
|
|
|
|
|
|
2023-11-16 00:07:41 +11:00
|
|
|
func _ready() -> void:
|
|
|
|
apply_central_impulse(direction * force)
|
|
|
|
|
|
|
|
|
2023-11-15 15:19:40 +11:00
|
|
|
func _process(delta: float) -> void:
|
|
|
|
time_alive += delta
|
|
|
|
|
|
|
|
|
2023-11-17 20:49:38 +11:00
|
|
|
func spawn_damage_indicator(pos):
|
|
|
|
if damage > 0:
|
|
|
|
var marker = damage_particle_scene.instantiate()
|
|
|
|
get_tree().root.add_child(marker)
|
|
|
|
marker.set_number(damage)
|
|
|
|
marker.position = pos
|
|
|
|
|
|
|
|
|
2023-11-15 15:19:40 +11:00
|
|
|
func _on_body_entered(_body: Node) -> void:
|
|
|
|
pass # Replace with function body.
|
|
|
|
|
|
|
|
|
|
|
|
@rpc("reliable")
|
|
|
|
func networked_kill():
|
|
|
|
queue_free()
|