CharacterBody2D basic movement

Godot Version

`godot engine 4 android app

Question

`hi I’m a total beginner
I was following the brackeys tutorial and and I came to the point where I was supposed to use the CharacterBody2D basic movement script to move the player character and I did but it didn’t work the player didn’t move (or I just didn’t know how to move it) thought maybe I did the instructions wrong so I started from scratch again meticulously following the instructions still same results I’m guessing the script worked but it just isn’t made for the android app or something but i don’t know
how can i fix this?

Post your code. Copy it from the Godot editor as text and post it here, enclosed within three backticks (i.e. ```). Also include a picture of your scene tree.

The problem could be anything, and without you providing us this information, the best we can do is make very bad guesses.

1 Like

Welcome to the community.

It’s kind of hard to guess what the issue in your code is without seeing it :slight_smile:

Could you post it (in a code block please!) so we can see what you are doing?

1 Like

You said you’re on Android? Did you press keys on a keyboard to move the character?

2 Likes

this is a screenshot to the node tree

and this is the code



const SPEED = 300.0
const JUMP_VELOCITY = -400.0

# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity")


func _physics_process(delta: float) -> void:
	# Add the gravity.
	if not is_on_floor():
		velocity.y += gravity * delta

	# Handle jump.
	if Input.is_action_just_pressed("ui_accept") and is_on_floor():
		velocity.y = JUMP_VELOCITY

	# Get the input direction and handle the movement/deceleration.
	# As good practice, you should replace UI actions with custom gameplay actions.
	var direction := Input.get_axis("ui_left", "ui_right")
	if direction:
		velocity.x = direction * SPEED
	else:
		velocity.x = move_toward(velocity.x, 0, SPEED)

	move_and_slide() ```

yes I’m on android
I didn’t press keys on a keyboard to move the character there were no keys in my screen
is this why i can’t find a way for the character to move ? I feel really dumb right now🤦‍♂️

brackeys uses keyboard keys to move the character so yeah if you don’t have those then you’ll need to find a different way of moving the character

1 Like

thanks for answering my stupid question😅
I will look for another way

For the record - your question was not stupid.

Reaching out for help when you don’t understand something rarely is.

5 Likes

thanks
I’m gonna learn gdscript to not embarrass myself like this again :joy::joy:

1 Like

I used to be stuck here, but it was solved later. I didn’t expect someone to stay at this stage like me, haha :see_no_evil_monkey:

1 Like

well one gotta start somewhere right?:joy::broken_heart: