![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | scrubswithnosleeves |
HI!
Godot 3.2.2 stable on macOS
I am trying to lerp a Vector2 during a physics process and tell the process to stop once the interpolation reaches the B value: Vector2(0,0)
. For some reason, the “if” statement comparing offset == Vector2(0,0)
does not seem to be working. When I print(offset)
, I can see that offset does equal one of the compared vector values, but it never runs the code of the if statement; in this case lerping = false
.
var shaking = true
var lerping = false
func _physics_process(delta):
if lerping == true:
offset = lerp(offset, Vector2(0,0), .3)
if offset == Vector2(0,0) or offset == Vector2(-0,0) or offset == Vector2(0,-0) or offset == Vector2(-0,-0):
lerping = false
if shaking == true:
offset += Vector2(rand_range(-25,25), rand_range(-25,25))* delta
lerping= true
print('lerping: ', lerping)
print('offset: ',offset)
func _on_ShakeTimer_timeout():
shaking = false
Here are the output prints:
...
lerping: True
offset: (0, 0)
Does anyone know what I am doing wrong? I will eventually be using this to set _process = false