How do i reset a variable to 0

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

So i need to know how to reset a variable after performing wall jumping when i land on the floor
Example: i jumped on a wall until i reached the maximum (3) after i land i cannot perform wall jump again as my variable for wall_jump_count = 3 which equals to max_wall_jump (3)
I need a block that reset the wall_jump_count back to 0 AFTER i land on the floor

:bust_in_silhouette: Reply From: Wakatta

Not much is known about your project structure so assuming you’re using PhysicsBodies connect the signal to the following

func on_body_collision(body):
    if "Floor" in body.name:
        if wall_jump_count >= max_wall_jump:
            wall_jump_count = 0

Oh yeah about that i already figured it out but in a different way down at physics process i added this code:

If is_on_floor:
   wall_jump_count = 0 

Seems to be working just fine but not sure it will be after the script gets more complex

Hexadotz | 2021-11-07 09:05

Should be fine.

A good practise is to put comments in your code blocks
So you know what makes or breaks what and debugging gets easier

Wakatta | 2021-11-07 22:58