It is a bit difficult to see what you are trying to do since you only gave a two line code excerpt, but you could put the code in your loop in the _process
function within an if statement that checks if the velocity meets the desired conditions. Then it would every frame check if the velocity meets the desired conditions and then run the code that you formerly had in a loop. Let's say that your current code is this:
func foo():
while true:
barify()
await velocity != Vector3.ZERO
You could instead do:
func _process(delta):
# other unrelated code
if velocity != Vector3.ZERO:
barify()
I should also note that it isn't possible to use the >
operator to compare two Vector3
s. I you want velocity
to be non-zero then you should do velocity != Vector3.ZERO
or something similar. If you want to check that at least one component of the velocity vector is positive and that none is negative you could do (velocity.x > 0 or velocity.y > 0 or velocity.z > 0) and not (velocity.x < 0 or velocity.y < 0 or velocity.z < 0)
.