I call it in the physics_process() funtion but experience that the direction doesn’t feel an Input I guess which makes direction a Vector2(0,0) → basically making the player movement = 0.
I tested holding down arrow_keys instead of keybord_keys (like W,A,S,D) which had the same problem, except when I held down both it was fixed.
A lot of missing context here that could be the cause:
Is _movement() always called within _physics_process() or is there an if/early return that could cause it to get skipped?
Is value of movement_speed being changed somewhere outside of _movement(), to value of 0 possibly, casuing the resulting velocity to be 0?
Are “left” / “right” / “up” / “down” correctly asigned in the input map?
Hard to tell by just this small bit of code - I don’t think there is something directly wrong with it. Gut feeling tells me that if it works when both (arrows and wasd) inputs are pressed, then option 1) might be more likely but it’s just a guess honestly.
_anim(direction):
if dir.x == 1:
$Sprites.play(“walking right”)
if dir.x == -1:
$Sprites.play(“walking left”)
if dir.y == 1:
$Sprites.play(“walking down”)
if dir.y == -1:
$Sprites.play(“walking up”)
if dir.x> 0.5 and dir.y< -0.5:
$Sprites.play(“walking upright”)
if dir.x> 0.5 and dir.y> 0.5:
$Sprites.play(“walking downright”)
if dir.x< -0.5 and dir.y< -0.5:
$Sprites.play(“walking upleft”)
if dir.x< -0.5 and dir.y> 0.5:
$Sprites.play(“walking downleft”)
I at first thought it may be performance issues but after stripping the whole main scene down to just the player it still was like before.