0 votes
func _physics_process(delta):
    position.x = lerp(position.x,500,1 * delta)

How do I detect when the node interpolation reaches that position?

when i do this it doesn't work

if position.x == 500:
in Engine by (196 points)

1 Answer

+2 votes

You're probably getting bit by your x position never being exactly equal to 500. Try this instead:

if is_equal_approx(position.x, 500):
    print("Lerp done!")
by (21,864 points)

but this method does not work for a vector2 position
how use this for

if is_equal_approx(position, Vecttor2(500,500)):
    print("Lerp done!")

You didn't ask about a Vector2 in the original question. You were checking a float value (position.x). There is a Vector2 version of this though...

if position.is_equal_approx(Vector2(500,500)):
    print("Lerp done!")
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.