0 votes

my problem is that I try to make a score where every time you eat an enemy a point is added to the punctuation but when I add it the score value is not updated and it remains with the one that defined the variable

in Engine by (12 points)

Show your code. No one can tell you what you're doing wrong if they can't see it.

Showing your code will help people figure out what may be wrong with it.

By just reading your problem, it might be the case that your score variable is updating, but your score display ( a label I assume?) is not updating. You could test this by printing your score to the console.
I had a similar problem where elements of my UI were not updating when variables were, so you need to make sure you call an update for the UI when the score needs updating.

Something like (from my phone, so psuedo);

var score = 0
var score_display = get_node("score_label")

func _ready():
score_display.text = str(score)

func add_points(points):
var new_score
new_score = score + points 

func update_score(score_new):
score = score_new
score_display.text = str(score)

But this is just a guess based on my experience, like kidscancode said, showing your code will help a lot.

Hope this helps.

Wouldn't score += points be suffice?

Hi Magso,
Yes you could write it that way instead. You can also merge the points and score update functions, I sometimes write things a different way to separate where different things are happening, I find it's easier to follow code that way, but it isn't always the fastest option.

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.