Godot Version
4.1.1 stable
Question
When i boot up my game the player just floats there none of my other code is working and i dont know why.
code
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
JUMP_VELOCITY = 0
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
else:
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
move_and_slide()