Godot Player Controller Script Generator (GDScript)
Pick a template, set speeds, input action names and options, and get a ready-to-attach Godot 4 GDScript file with typed exported variables. Templates cover a 2D platformer character controller with coyote time and jump buffering, 2D top-down movement, a 3D first-person controller, a simple state machine, a health component with signals and an autoload singleton, and each one lists the nodes it expects.
How to use it
- Choose a template, such as 2D platformer or 3D first-person, then press Next.
- Set the speeds, toggles and input action names, or press Reset to defaults, then press Next.
- Check the summary on the Review step and press Generate script.
- Press Copy code or Download .gd, then follow the Node setup list under the code.
- Press Copy Ziva prompt to have Ziva build a playable test scene around the script.
Coyote time and jump buffering in Godot
Coyote time lets the player jump for a short moment after running off a ledge, and a jump buffer remembers a jump press made just before landing. Both forgive inputs that are a few frames early or late, which players read as responsive controls rather than missed jumps. Values around 0.1 seconds are a common starting point; tune them by playing.
In the generated platformer script, a coyote timer is refilled every physics frame while is_on_floor() is true and counts down in the air, and the jump buffer timer is set when the jump action is pressed and counts down every frame. A jump happens when both timers are above zero, then both reset so one press cannot trigger two jumps. The short hop option multiplies upward velocity by jump_cut when jump is released early, giving a lower jump for a tap.
Jump height follows from jump_velocity and gravity: height = jump_velocity squared / (2 x gravity). With the default 2D gravity of 980 pixels per second squared and a jump velocity of 450, that is 202500 / 1960, about 103 pixels. To jump over a 3-tile wall with 32 pixel tiles (96 pixels), you need at least the square root of 2 x 980 x 96, about 434 pixels per second.
How these scripts differ from Godot's built-in templates
Godot's CharacterBody2D Basic Movement template uses constants (SPEED = 300.0, JUMP_VELOCITY = -400.0), the built-in ui_left, ui_right and ui_accept actions and instant acceleration. The generated scripts use @export variables so you can tune speeds in the Inspector while the game runs, your own input action names, and optional acceleration and friction with move_toward().
Gravity comes from get_gravity(), added to CharacterBody2D and CharacterBody3D through PhysicsBody in Godot 4.3. It returns the project's default gravity (Project Settings > Physics > 2D > Default Gravity, 980 by default) plus any Area2D or Area3D gravity overrides, so water or low-gravity zones work without extra code. That is why the scripts need Godot 4.3 or newer.
The top-down script sets motion_mode to MOTION_MODE_FLOATING, which Godot's class reference describes as the mode for games with no notion of floor or ceiling, such as top-down games: every collision counts as a wall and sliding keeps a constant speed.
Using the health component and autoload
The health component is a plain Node you add as a child of any player or enemy. It emits health_changed(current, maximum), damaged(amount), healed(amount) and died, so a health bar, hit flash and death animation can each connect to a signal instead of checking health every frame. With a class_name, the script also shows up in the Create New Node dialog and works as a type hint.
An autoload is a node Godot adds to the root of the scene tree before your main scene, reachable by name from every script. Register the script in Project > Project Settings > Globals > Autoload. Do not give the script a class_name equal to the autoload name: Godot rejects it with the error that the class hides an autoload singleton.
The autoload's save option writes the high score as JSON to user://save.json with FileAccess. Godot guarantees user:// is writable, even in an exported game, while the project folder (res://) is likely read-only once the game ships.
Frequently asked questions
Which Godot version do these scripts work with?
Why does my player not move after adding the script?
What is coyote time?
Can I use the first-person controller with a gamepad?
Is the GDScript generator free?
More free game dev tools
- Godot Input Map Generator: Godot 4 input actions for keyboard, mouse and gamepad, as an autoload or a project.godot section.
- Godot Shader Generator: Pick a 2D effect, tune its uniforms with a live preview and download a Godot 4 .gdshader.
- Godot 3 to 4 Converter: Rule-based GDScript upgrade from Godot 3 to Godot 4, with a line-by-line change list and manual-work warnings.