Any help with this, character is not moving?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By micah_pee
if direction.x != 0 && state_machine.check_if_can_move():
    velocity.x = direction.x * speed
    velocity.x = move_toward(velocity.x, 0, speed)

Edited to fix forum code formatting…

jgodfrey | 2023-06-15 01:36

Really not enough context on this one.
Is it a RigidBody2D? You might be trying to use linear_velocity instead.
Do you see any errors?
What is move_toward?

sirdorius | 2023-06-15 12:29

:bust_in_silhouette: Reply From: Bean_of_all_Beans

Since you wrote velocity and not linear_velocity, I’m assuming you’re trying to get a CharacterBody2D.

If this is the case, ensure you also call move_and_slide(). This will have the CharacterBody2D move with whatever you set velocity to.