← Pixel Dreamer Studio

Kick a RigidBody3D ball with the same strength at any tick rate

Use apply_central_impulse() with speed times mass for a kick, instead of one call to apply_central_force().

apply_central_force() pushes for one physics step only, so one call adds force × step time ÷ mass. In our Godot 4.7 test 300 N on a 0.45 kg ball gave 22.22 m/s at 30 physics ticks per second, 11.11 at 60, 5.56 at 120 and 2.78 at 240. For a kick use apply_central_impulse(direction * speed * mass): the ball gets exactly that speed at any tick rate.

The code

Put this script on the ball. Call kick() once, on the frame the foot or the club hits. For a charge shot, pass power from 0 to 1, for example how long the button was held divided by the full charge time.

extends RigidBody3D
## Ball that gets the same kick at any physics tick rate.
## Call kick(direction, power) once, on the frame the foot hits. power goes from 0 to 1 (charge shots).

@export var full_kick_speed := 25.0  # m/s added by a full-power kick
@export var lift := 0.15  # how much of the kick goes upward


func kick(direction: Vector3, power := 1.0) -> void:
	var dir := Vector3(direction.x, 0.0, direction.z).normalized()
	dir = (dir + Vector3.UP * lift).normalized()
	var speed := full_kick_speed * clampf(power, 0.0, 1.0)
	# An impulse changes the speed at once (speed change = impulse / mass).
	# apply_central_force() only lasts one physics step, so its kick depends on the tick rate.
	apply_central_impulse(dir * speed * mass)

What we measured

A real RigidBody3D ball, 0.45 kg, with gravity and damping turned off, at 30, 60, 120 and 240 physics ticks per second. Two runs with the same numbers.

Why it happens

A force is per second. Godot applies one call for a single physics step, 1/60 of a second at 60 ticks, and then it is gone. Double the tick rate and the same call pushes for half as long. It is also why a kick made with a force feels weak: 300 N sounds like a lot, but 1/60 of a second of it only adds 11 m/s to a football. An impulse is the push already added up, so the speed changes by impulse divided by mass, whatever the step length. Keep apply_central_force() for pushes you repeat every physics frame, like wind or a current.

What to change

Show where the ball will go before the kick: predict a ball trajectory line.

Ready-made ball game effects: Sports & Ball Game VFX for Godot 4 has 32 presets in Stylized and Retro PSX looks, including charge shots, kick impacts, ball trails, a Trajectory Preview and a goal net ripple.

Tested in Godot 4.7 with the Compatibility renderer.

Ready-made: Sports & Ball Game VFX for Godot 4 has 32 ready-made sports effects in Stylized and Retro PSX looks, including charge shots in 3 levels, kick impacts, ball trails and a goal net ripple.

More how-tos: Projectiles and aiming