#Can someone explain this variables assignments pls
5 messages · Page 1 of 1 (latest)
it is being overwritten however if you think about this operation
var x
x = 1
x = x + 1
print(x) => 2```
because velocity is an argument in the `move_and_slide` function it is not lost, it is modified and the result of move_and_slide is returned and assigned to the velocity variable, like above the result of adding 1 to x was assigned to x.
so at the first moment velocity is just Vector2.ZERO from the parent's script, then on the line 7 I modified it to the returned expression of calculate_move_velocity and this result is passed as an argument of move_and_slide on the next line?
That sounds correct. And on line 8 you assign it again as the return value of move and slide.
Oh, nice