Game controls and gravity not working

Godot Version

4.1.1 stable


When i boot up my game the player just floats there none of my other code is working and i dont know why.


extends CharacterBody2D
class_name Player

var SPEED = 300.0
var JUMP_VELOCITY = -400.0
var isinwater = false
var grav_modifier = 1
var control = 1

var gravity = ProjectSettings.get_setting(“physics/2d/default_gravity”)*grav_modifier
func inwater():
SPEED = 200
gravity = 0
isinwater = true
grav_modifier = 0

func _physics_process(delta):
if not is_on_floor() and not isinwater:
velocity.y += gravity * delta
if Input.is_action_just_pressed(“Up”) and is_on_floor():
velocity.y = JUMP_VELOCITY
velocity.y += 10
if Input.is_action_just_pressed(“Down”) and isinwater:
velocity.y += 10
if Input.is_action_just_pressed(“Right”):
velocity.x += 10
if Input.is_action_just_pressed(“Left”):
velocity.x -= 10

Please, surround your code with triple back quotes (```your_code``` – the key above left tab), it’ll preserve tabulation, which is important in case of GDScript language. It should look like this (on your right you can preview the post):

func make_funny():