0 votes

please help
queue_free does work but the var does not change when kinimaticbody2d entered

extends Area2D

var score = 0

func onBugbodyentered(body):
score += 1
queue_free()

extends Label

func _process(delta):
self.text = str(Bug.score)

Godot version newest
in Engine by (12 points)

Try this:

extends Area2D

func onBugbodyentered(body):
    body.score += 1
    queue_free()

1 Answer

0 votes

What is supposed to happen in this project ?
Bug earns its own score on collision and immadietely dies. So every Bug in your game has 1 score in total lifetime :). Is Bug main player or enemy ? You mixed something up, You propably want one global score, not a lot of locals ?

by (7,755 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.