Is there an automatic/internal limit on variable values? (_physics_process() related question)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By toec

I’ve done a number of tutorials, and among them I see people coding a Kinematic2D body to “jump” via subtracting gravity from velocity

If your sprite has just jumped up and velocity is something like -250, subtracting a gravity value of 10 each _physics_process() cycle results in the character falling back to the platform they started on, which is great.

But if you then do nothing, and just let the game run, I would assume that _physics_process just keeps on subtracting gravity from velocity, eventually resulting in velocity being a rather large number.

Is there an internal limit on such things that allows one to not worry about that, or is this something the tutorials are overlooking for the sake of simplicity?

I think when the Kinematic2D is on floor using move_and_slide() and floor_normal to determine the floor the move_and_slide function ignores sets the y value automatically to 0. but I still don’t understand 100% what move_and_slide actually does.

for example I don’t understad what does setting the vel var to move and slide.

_velocity = move_and_slide(_velocity,Vector3.UP)

axilirate | 2020-04-05 08:25