extends Node3D @export var speed: int = 0 @export var damage: int = 0 @onready var mesh = $RigidBody3D/MeshInstance3D @onready var rigid_body_3d: RigidBody3D = $RigidBody3D @onready var ray = $RigidBody3D/RayCast3D @onready var particles = $GPUParticles3D # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): var time_per_frame: float = 1 / Engine.get_frames_per_second() var distance: float = time_per_frame * speed * 1.5 ray.target_position.z = distance position += transform.basis * Vector3(0, 0, speed) * delta rigid_body_3d.set_use_continuous_collision_detection(true) #ray.collision_mask = 1 #ray.enabled = 1 if ray.is_colliding(): var collider = ray.get_collider() if collider != null and collider.is_in_group("target"): ray.get_collider().take_damage() if collider != null and collider.is_in_group("body"): ray.get_collider().hit(damage) rigid_body_3d.visible = false particles.emitting = true #if ray.get_collider().is_in_group("body"): #print("head") await get_tree().create_timer(1.0).timeout queue_free() func _on_timer_timeout(): queue_free()