DaveTheCoder You have to provide the function "die" in your script. It's not a built-in function.
I did provide on in another node, the way this works is that I have a function in a node, that node is stated in an @export variable, just like a label or a timer, and when you say timer.start() as a function in the node's built in script, it is like saying blue_streak.die().
I realize that I prabably should have included that information from the start of this topic, I'm sorry for causing this confusion, but I intend to fix it right here.
So you can understand the problem more, here are both scripts:
Obstacle:
extends Area2D
@onready var blue_streak: CharacterBody2D = $"."
# 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: float) -> void:
pass
func _on_body_entered(body: Node2D) -> void:
blue_streak.die()
Character:
extends CharacterBody2D
@onready var time_display: Label = $"time-display"
@onready var throttle_display: Label = $"throttle-display"
@onready var stopwatch: Timer = $stopwatch
@onready var explosion: AnimatedSprite2D = $explosion
@onready var death_message_timer: Timer = $"death-message-timer"
@onready var reset_timer: Timer = $"reset-timer"
@onready var death_message: Label = $"death-message"
var throttle = 0
var time=0
@onready var started=false
func _ready() -> void:
explosion.hide()
death_message.hide()
func _process(delta: float) -> void:
if Input.is_action_just_pressed("throttle_up") and (started==false):
stopwatch.start()
started=true
#throttle-handlers
if Input.is_action_pressed("throttle_up"):
throttle +=10
started=true
elif Input.is_action_pressed("throttle_down"):
throttle-=10
if(throttle < 0):
throttle=0
if(throttle > 500):
throttle=500
throttle_display.text="Speed: "+str(throttle)
time_display.text="Time: "+str(time)
func _physics_process(delta: float) -> void:
#speed-handler
velocity.y=throttle
move_and_slide()
func _on_time_timeout() -> void:
time+=.5
stopwatch.start()
func die():
explosion.show()
death_message_timer.start()
func _on_deathmessagetimer_timeout() -> void:
death_message.show()
reset_timer.start()
func _on_resettimer_timeout() -> void:
get_tree().reload()
I hope this clears up any confusion.