23 lines
505 B
GDScript3
23 lines
505 B
GDScript3
|
extends RigidBody2D
|
||
|
|
||
|
@export var cancel_time: float = 3.0
|
||
|
@export var cancel_speed: float = 50.0
|
||
|
@export var lethal_speed: float = 100.0
|
||
|
|
||
|
var lifetime: float = 0.0
|
||
|
|
||
|
func _process(delta: float) -> void:
|
||
|
lifetime += delta
|
||
|
if lifetime >= cancel_time:
|
||
|
cancel()
|
||
|
elif linear_velocity.length() <= cancel_speed and lifetime >= 0.1:
|
||
|
cancel()
|
||
|
|
||
|
func cancel() -> void:
|
||
|
queue_free()
|
||
|
|
||
|
func _on_body_entered(body: Node) -> void:
|
||
|
if linear_velocity.length() >= lethal_speed:
|
||
|
if body is Enemy:
|
||
|
body.kill()
|