How do i make a rigid body jump in a plaformer game here is my code can u fix it

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

extends RigidBody2D

func _physics_process(delta):

if Input.is_action_pressed("right"):
	apply_impulse(Vector2(), Vector2(5, 0))
if Input.is_action_pressed("left"):
	apply_impulse(Vector2(), Vector2(-5, 0))

if Input.is_action_pressed("up"):
	apply_impulse(Vector2(), Vector2(0, -5))
:bust_in_silhouette: Reply From: Gluon

Okay so full disclosure I dont use rigid bodies in my games but as nobody has answered you I will do my best. I think probably the problem here is you are only applying a very small force each time you press the button, I suggest changing the forces from 5 to something more like 300.

I cannot promise this will work but it would be the first thing I would try.

If that doesnt work try adding self to the call

if Input.is_action_pressed("right"):
    self.apply_impulse(Vector2(), Vector2(5, 0))

Gluon | 2023-02-08 00:08