My code is supposed to reset the ceane only when the spaceship leaves the track, but it seams to reset within the track when I go too fast as well. And whenever I run it, the debugger spits out
“Warning: The parameter “body” is never used in the function " on_a _maz_eing_body_exited". If this is intended, prefix it with an underscore: " body".
GDScript Error: UNUSED_PARAMETER
GDScript Source: level.qd:7“
and this does not rectify when I underscore “_body“.
in addition, when the code resets the debugger spit out
“Error: level.gd:8 @ _on_a _maz_eing_body_exited): Removing a CollisionObject node during a physics callback is not allowed and will cause undesired behavior. Remove with call deferred() instea
C++ Source: scene/2d/physics/ collision_object 2d.cp:98 @ _notification0
Stack Trace:
level.gd:8 @_on_a_maz_eing_body _exited!)“
I never told it to remove anything! All the code is identical to the teacher’s, and he never addresses the problem.
The code in question.
extends Node2D
# Called when the node enters the scene tree for the first time.
func _ready():
pass
func _on_a_maz_eing_body_exited(body):
get_tree().reload_current_scene()
Additional code that might be the problem, but I doubt it.
extends RigidBody2D
var force = 620
func _ready():
var addition_result = add(10, 5)
print(addition_result)
func _physics_process(_delta):
if Input.is_action_pressed(“move_right”):
apply_force(Vector2(force, 0))
if Input.is_action_pressed(“move_left”):
apply_force(Vector2(-force, 0))
if Input.is_action_pressed(“move_up”):
apply_force(Vector2(0, -force))
if Input.is_action_pressed(“move_down”):
apply_force(Vector2(0, force))
func add(No1, No2):
var result = No1 + No2
return (result)
Thank you for helping.




