With this code before I added the variable "canjump" I could make the main character (which in this case is a simple ball with RigidBody) jump, but it could jump infinite times before touching the floor again. So I hope someone can help me make it jump only one time after each time it touches the floor. The variable seems to be working when the scene starts, because the ball can jump one time, but after that, it can't jump anymore. I'm new to coding in GD, so please let me know any mistake in this code. For example, two of the things I don't know are whether the variables are in the correct lines and the correct code for collision with the floor which is a StaticBody.
extends Spatial
#
var canjump = true
#
func _ready():
set_process_input(true)
pass
#
func _input(event):
#
if event.is_action_pressed("SPACE") and not event.is_echo() and canjump==true:
self.get_node("BallRigidBody").apply_impulse(Vector3(0,0,0),Vector3(0,10,0))
canjump=false
#
func on_StaticBody_body_enter( body ):
var name = body.get_name()
if name == "FloorStaticBody":
canjump=true