- Edited
I'm trying to add a force while also having a velocity next to it, since I want to make the player move left and right with the velocity and jump with the force.
This is my code:
extends RigidBody2D
func _process(delta):
var velocity = Vector2.ZERO
if Input.is_action_just_pressed("jump"):
apply_force(Vector2(0, -30000))
if Input.is_action_pressed("left"):
velocity -= 1
if Input.is_action_pressed("right"):
velocity += 1
The game itself works as I intended, including the jumping, but if I press left or right, this error message will appear:
How do I make the character move left and right, and make him jump too?