Character not moving

Godot Ver 4, android version running on chrome book

Character body doesn’t seem to be moving even though I’m using some simple movement stuff

You’ll need to post some code and maybe some screenshots, otherwise nobody can really determine what’s wrong.

1 Like

extends CharacterBody2D

const max_speed = 400
const accel = 1500
const friction = 600

var input = Vector2.ZERO

func _physics_process(delta):
player_movement(delta)

func get_input():
input.x = int(Input.is_action_pressed(“Right”)) - int(Input.is_action_pressed(“Left”))
return input.normalized()

func player_movement(delta):
input = get_input()

if input == Vector2.ZERO:
	if velocity.length() > (friction * delta):
		velocity -= velocity.normalized() * (friction * delta)
	else:
		velocity = Vector2.ZERO
else:
	velocity += (input * accel * delta)
	velocity = velocity.limit_length(max_speed)

move_and_slide()

this was from a YouTube tutorial, and iirc it’s worked for me before, just not in this version

(Please use the </> button in the edit toolbar to format your code.)

I don’t see anything wrong with that code, and I pasted it into a new project and it seems to work fine (character moves left and right as expected, no gravity).

Do you get any errors in the console? Are your Input Map actions set up with proper key events? Does anything change if you use the "ui_right" and "ui_left" events instead?

1 Like

I got help from some people and yeah, it looks like an android-chrome book problem. I tried it on the web version and it worked fine. Thanks for taking the time to help though :slight_smile:

2 Likes