func _physics_process(delta): isn't running

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By undead_rat

I’m new to godot, so I really may of just made a dumb mistake, but func _physics_process(delta): isn’t running. It was yesterday, but after making some changes it’s stopped.

func _physics_process(delta):

print("Hello world")

velocity.x = 0
velocity.y = 0


if Input.is_action_pressed("move_left"):
	velocity.x -= speed * acceleration * delta
	sprite.flip_h = true
	
	
if Input.is_action_pressed("move_right"):
	velocity.x += speed * acceleration * delta
	sprite.flip_h = false
	
if Input.is_action_pressed("move_down"):
	velocity.y += speed * acceleration * delta
	
if Input.is_action_pressed("move_up"):
	velocity.y -= speed * acceleration * delta
	
	
velocity = move_and_slide(velocity, Vector2.UP)

Theres no output, including from “Hello world”, and the sprite is no longer moving. No errors are being thrown up by the debugger, so I’m not sure what the issue could be. Any ideas?

Please fix the formatting of your code for the forum. While it’s mostly right, the function name itself is misformatted.

jgodfrey | 2022-08-27 21:55

:bust_in_silhouette: Reply From: Ertain

Is this the contents of the _physics_process() function? BTW, may I suggest adding and subtracting “1” from the velocity variable, and not factoring in delta for the move_and_slide() function, as it already factors that in.

...
if Input.is_action_pressed("move_right"):
    velocity.x += 1
    sprite.flip_h = false

if Input.is_action_pressed("move_down"):
    velocity.y += 1
...