Build the line by stepping through the same physics the ball uses: add gravity, apply linear damping, move, once per physics tick. A new Godot project damps every RigidBody3D by 0.1 (default_linear_damp), and the parabola formula leaves that out. In our Godot 4.7 test the formula put the ball down 12.37 m away, the real ball came down at 11.15 m, and the script below said 11.16 m.

The code
Add this node to your level and call show_path(start, velocity) every frame while the player aims, with the same velocity you will give the ball. landing holds the first point the path hits, for a target marker. If the ball is already at the start point, pass its RID in exclude so the line does not stop on the ball itself.
extends Node3D
## Draws the path a thrown or kicked ball will take, and where it lands, before you throw it.
## It steps through the same physics as a RigidBody3D, gravity and linear damping,
## one physics tick at a time, so the line and the real ball agree.
## Call show_path(start, velocity) while aiming. Pass the ball's RID in "exclude" so the line does not hit the ball.
@export var max_time := 3.0 ## seconds of flight to look ahead
@export var color := Color(1.0, 1.0, 1.0, 0.85)
var landing := Vector3.INF ## where the path first meets something, INF if it does not
var _mesh := ImmediateMesh.new()
func _ready() -> void:
var line := MeshInstance3D.new()
line.mesh = _mesh
line.top_level = true # the points are in world space
line.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
var m := StandardMaterial3D.new()
m.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
m.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
m.albedo_color = color
line.material_override = m
add_child(line)
func predict(start: Vector3, velocity: Vector3, ball_damp := 0.0, exclude: Array[RID] = []) -> PackedVector3Array:
var dt := 1.0 / Engine.physics_ticks_per_second
var gravity: Vector3 = ProjectSettings.get_setting("physics/3d/default_gravity") * ProjectSettings.get_setting("physics/3d/default_gravity_vector")
# the project's default damping (0.1 in a new project) is added to the ball's own linear_damp
var damp: float = ProjectSettings.get_setting("physics/3d/default_linear_damp") + ball_damp
var space := get_world_3d().direct_space_state
var pts := PackedVector3Array([start])
var p := start
var v := velocity
landing = Vector3.INF
for i in int(max_time / dt):
v += gravity * dt
v *= maxf(0.0, 1.0 - damp * dt)
var q := PhysicsRayQueryParameters3D.create(p, p + v * dt)
q.exclude = exclude
var hit := space.intersect_ray(q)
if hit:
landing = hit.position
pts.append(landing)
return pts
p += v * dt
pts.append(p)
return pts
func show_path(start: Vector3, velocity: Vector3, ball_damp := 0.0, exclude: Array[RID] = []) -> void:
var pts := predict(start, velocity, ball_damp, exclude)
_mesh.clear_surfaces()
if pts.size() < 2:
return
_mesh.surface_begin(Mesh.PRIMITIVE_LINE_STRIP)
for pt in pts:
_mesh.surface_add_vertex(pt)
_mesh.surface_end()
What we measured
A ball of radius 0.11 m thrown from 1 m up at 8 m/s forward and 7 m/s up, over a flat floor, at 60 physics ticks per second. We compared how far it had gone when its centre came down to 0.11 m above the floor, where the ball touches.
- Parabola formula, no damping: 12.368 m.
- The script's steps without damping: 12.244 m.
- The script as written: 11.163 m.
- The real RigidBody3D: 11.147 m. The formula was 1.22 m too far, the script 1.6 cm.
- A ball with its own
linear_dampset to 0.5: the real ball 7.511 m, the script withball_damp0.5 said 7.551 m.
Two runs gave the same numbers.
Why the formula misses
Most of the gap is damping, not the stepping: steps without damping still landed 1.1 m too far. physics/3d/default_linear_damp is 0.1 in a new project and slows every moving body a little each tick, and a body's own linear_damp is added to it. The script reads both from the same settings, so it stays right if you change them.
What to change
max_time: how many seconds ahead to look. Longer for a long kick, shorter to show only the start of the arc as a hint.ball_damp: pass the ball's ownlinear_dampif you set one.- The line is the path of the ball's centre and stops where it meets a surface. The ball itself touches a little before that, by about its radius.
Ready-made ball effects: Sports & Ball Game VFX for Godot 4 has 32 presets in Stylized and Retro PSX looks, including a Trajectory Preview, ball trails, charge shots, kick impacts 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 a Trajectory Preview, ball trails, charge shots, kick impacts and a goal net ripple.
More how-tos: Projectiles and aiming
- A ball that hits the net however hard it is kicked
- A shot that meets a moving target
- An Area3D that does not see a bullet or another area
- A fire rate that holds at any frame rate
- Point swords, projectiles and models that face +Z at the target
- FPS shots that land on the crosshair
- A spell that keeps flying straight after it leaves the hand
- Turn towards a target the short way round
- A laser beam that stops where it hits, the moment you aim
- Fast projectiles that never fly through enemies
- Aim a spell at the mouse on a 3D floor
- A homing missile that turns, but not instantly
- Particles fall sideways when you rotate the emitter
- Particles that fly into the player
- Gaps in the trail of a fast emitter
- Make a tower shoot the enemy closest to your base
- Hit the target with an arcing shot at any angle and height
- Kick a RigidBody3D ball with the same strength at any tick rate
- Reload without losing or making up rounds
- Fan out any number of projectiles evenly around the aim direction
- Recoil that settles back to where the player aims