Hi! I try to make racing game, my car moves within the borders of tile map, but finish line is not working and I have no idea what I do wrong. All help is apreciated
main script (I switched variable rounds for a global variable but it didn’t do much)
extends Node2D
var rounds = 0
var win = 0
@onready var ui = $bumpcars_player/Camera2D/UI_end_scene
# Called when the node enters the scene tree for the first time.
func _ready():
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if Global.racer_rounds >= 1:
win = 1
if win == 0:
ui.hide()
elif win == 1:
print("win")
ui.show()
else:
print("lost")
func _on_meta_body_entered(body):
Global.racer_rounds += 1
Meta is area2D node that is my finish line, it includes colision2D node. Area 2D should be sending a signal to main script, but it’s not working quite right
Does your car_body’s collision mask check for the finish_line’s collision layer?
One of your objects must have an “on_body_entered” signal that is processed
Please add a print statement inside your _on_meta_body_entered method to see if it prints out anything.
Right now I assume that
but finish line is not working
means the collision detection of the car touching the finish line does not work.
This means either the collision layers and masks are not correct, or the signal is not connected yet.
Please check if your method has the green signal arrow