#Can someone explain this variables assignments pls

5 messages · Page 1 of 1 (latest)

green bluff
#

Hi guys, I'm watching Gdquest's platformer tutorial and don't understand how "velocity" is being used twice here, can someone help me? how this isn't overriding? Also, when I pass as func params I'm using the "velocity" from the parent script?

lapis flax
green bluff
#

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?

lapis flax
#

That sounds correct. And on line 8 you assign it again as the return value of move and slide.

green bluff
#

Oh, nice