0 votes

Here is a pic of my problem while I'm debugging:

enter image description here

So in line 10, I check the tileLoc variable which is 0 as you can see at the bottom, but my code is skipping to line 16 instead of executing line 11-13. Am I having some sort of brain fart here and missing something simple?

Thanks in advance for any help.

in Engine by (34 points)

3 Answers

+3 votes
Best answer

get_translation().x is float value and comparing equality float value is not good idea.
It's better to compare range or distance, like if abs(get_translation().x) < 0.001

by (9,509 points)
selected by

I'll give it a try a little later. Thanks!

changing it to tileLoc > -0.1 did the trick. Thanks!

0 votes

not sure if this is your problem, but it seems the error shown is one line below than what it should show, so your error might actually be at the else: line which is actually at the if line.. This is a problem with the editor, and I saw this in every error I get.: errors are above the line indicated by debugger.
To test this further put something ,( a print line )inside the else function and see if it gets printed.

by (518 points)

There's no error message, that's just telling me where my current step in the debugging process is. I think it's a float problem that the other 2 answers are talking about.

+1 vote

float precision problem is assume:


var a = 0.00000000000000001
if (a == 0):#debugger will say a is 0, but its not
    #will not fire

so use distance like volzhs suggested

by (289 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 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.