Need help with Rigidbody2D ball physics

Godot Version

Godot 4


i’m new to godot and game dev in general. i’ve already made a 2d plataformer and a flappy bird clone by myself and figured i might try recreating the game soccer heads. I searched on youtube and learnt how to apply forces and all of that to the rigidbody but if i stand on the ball it launches the player off, and the ball also goes crazy, is there any way to make it so it has normal ball physics?

extends RigidBody2D

func _on_area_2d_area_entered(area):
	if == "Jugador":
		apply_central_impulse(Vector2(1000 * Globales.Direc,0))

i have a global variable that checks the direccion of the player, and an area2d on the same player that when the ball enters in it it applies an impulse.
If anyone can help me i would be glad

I am also new to godot but let me answer:

Doc on apply_central_impulse:

Applies a directional impulse without affecting rotation.

An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the “_force” functions otherwise).

This is equivalent to using apply_impulse at the body’s center of mass.

One simple (maybe bad) solution is to make a variable bool is_kicked in the ball, and apply impulse only if not is_kicked?

1 Like

Thanks! it kinda worked, i just changed the add impulse to an add force, and tweaked the parameters a little and now it’s better. I’ve also implemented the kick action, and for that i used the impulse. It’s not perfect but it’s something, thanks again

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.