the script that is attached to a sprite in a project (which is a PRESET btw, the basic movement one for characterBody2D) isn`t altering the sprite at all, the script runs upon running the project , i tried attaching it to the player scene and the instance in the game object, the script is being shown as next to the player in the hierarchy, heres the code if you want it
func _physics_process(delta: float) → void:
# Add the gravity.
print(“script running”)
if not is_on_floor():
velocity.y -= 300 * 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("go_left", "go_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
I am assuming that your print statement is printing “script running”.
This line: var direction := Input.get_axis("go_left", "go_right")
requires that you have “go_left” and “go_right” defined in the project settings input map.
These are not the default names so I am guessing that is your issue.
Open the project settings and then click on input map. Then click on show built in actions to make sure you are seeing all of them.
Then scroll the list. If you don’t see “go_left” or “go_right” then there is the problem.
You will see “ui_left” and “ui_right” (unless you have changed something) so use those two instead. var direction := Input.get_axis("ui_left", "ui_right")
no , those are changed to be in the input map go_left and go_right , in fact this was someting i changed to try and get it to work , and even if those caused bugs , the entire script isn`t working including the gravity , which in the tutorial i was following was what it was supposed to do
it is printing script running , but it is not executing anything on the sprite when i run the program
The camera is a child of the player, if the player moves so do it’s children. Thus appearing like nothing is moving because you do not have anything else in the scene.
@gertkeno I got hit by that early when starting in Godot - I created a large green texturerect and couldn’t understand why my movement code wasn’t working.