Is there a way to prevent errors from occurring in the function '_process' without using 'delta'?

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

I just started using this engine, and was in the middle of making a player movement script.

var velocity = Vector2(0,0)
const SPEED = 4
const GRAVITY = 0.5
const JUMP = -10
func _physics_process(delta):
if Input.is_action_pressed("right"):
	velocity.x = SPEED
if Input.is_action_pressed("left"):
	velocity.x = -SPEED
	
velocity.y = velocity.y + GRAVITY

if Input.is_action_pressed("up"):
	velocity.y = JUMP
	
velocity = move_and_collide(velocity)

velocity.x = lerp(velocity.x,0,0.2)

I was testing out this portion, and kept getting prompt with the error “The argument “delta” is never used in the function _physics_process.” I tried using " _delta" instead, but my game still wont run.

That is a warning, not an error message. It has no impact on your game running. If your game isn’t running, that’s an entirely different problem.

kidscancode | 2021-05-03 22:23

In the project settings, have you changed the settings to treat warnings as errors? That could be the problem.

magicalogic | 2021-05-04 11:50

:bust_in_silhouette: Reply From: Ertain

Did you try factoring in delta here?

 move_and_collide(velocity * delta)
:bust_in_silhouette: Reply From: scrubswithnosleeves
  1. This is a warning, not an error. To solve it, just put an underscore in front of delta

  2. You should be using delta. Use move_and_slide() instead of move_and_collide(). it is better for many reasons, especially for beginners, and it also incorporates delta automatically.