Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | eclipse682 |
I keep changing a variable with a timer, but the changed variable doesn’t affect my
_physics_procress(delta) function. Any idea why? The timer is working as the print function in this code works
extends Area2D
var speed=30
var dir=Vector2(0,0)
func _on_Timer_timeout():
print("timeout")
var randnum=rand_range(1,8)
if(randnum==1):
dir=Vector2(0,1)
if(randnum==2):
dir=Vector2(0,-1)
if(randnum==3):
dir=Vector2(1,0)
if(randnum==4):
dir=Vector2(-1,0)
if(randnum==5):
dir=Vector2(1,1)
if(randnum==6):
dir=Vector2(1,-1)
if(randnum==7):
dir=Vector2(-1,1)
if(randnum==8):
dir=Vector2(-1,-1)
func _physics_process(delta):
translate(speed*dir)