jame581/godotprompter/math-essentials
Claude Code and agent skill by jame581/godotprompter
- community
Checking that the SKILL.md file is still in the repository.
Use when implementing game math — vectors, transforms, interpolation, curves, random number generation, and common geometric recipes
Install
npx vskill@latest install jame581/godotprompter/math-essentialsSKILL.md
The same SKILL.md was published earlier as jame581/godotprompter/math-essentials.
Game Math in Godot 4.3+
All examples target Godot 4.3+ with no deprecated APIs. GDScript is shown first, then C#.
Related skills: player-controller for movement physics, ai-navigation for pathfinding math, camera-system for camera interpolation, tween-animation for easing curves, physics-system for collision math.
1. Vector Operations
Essential Vector Methods
| Method | Returns | Description | |
|---|---|---|---|
length() | float | Magnitude of the vector | |
length_squared() | float | Squared magnitude (faster, skip sqrt) | |
normalized() | Vector | Unit vector (length 1) in the same direction | |
distance_to(b) | float | Distance between two points | |
distance_squared_to(b) | float | Squared distance (faster for comparisons) | |
direction_to(b) | Vector | Normalized direction from this to b | |
angle_to(b) | float | Angle in radians between two vectors | |
angle_to_point(b) | float | Angle from this point to b (2D) | |
dot(b) | float | Dot product | |
cross(b) | float/Vector3 | Cross product (2D returns float, 3D returns vector) | |
rotated(angle) | Vector2 | Rotated by radians (2D) | |
move_toward(to, delta) | Vector | Move toward target by at most delta | |
clamp(min, max) | Vector | Clamp each component | |
snapped(step) | Vector | Snap to grid | |
reflect(normal) | Vector | Reflect off a surface | |
bounce(normal) | Vector | Bounce off a surface (inverted reflect) | |
slide(normal) | Vector | Slide along a surface |
Direction and Distance
Dot Product
The dot product tells you how aligned two vectors are.
Cross Product (3D)
The cross product gives a vector perpendicular to two input vectors.
2. Transforms
Transform2D
A 2D transform holds position, rotation, and scale.
Transform3D & Basis
is_orthonormal() (Godot 4.7+)
Basis.is_orthonormal() (const) returns true if the basis is orthogonal (axes perpendicular to each other) and normalized (every axis has length 1.0) — especially useful during physics calculations. It complements orthonormalized(): check first, and only re-orthonormalize when accumulated floating-point drift has denormalized the basis.
3. Interpolation
lerp — Linear Interpolation
Warning:lerp(a, b, speed * delta)is frame-rate dependent and never fully reaches the target. For precise movement, usemove_toward()instead.
move_toward — Fixed-Speed Approach
slerp — Spherical Interpolation
For smooth rotation interpolation (preserves arc, not straight line).
smoothstep — S-Curve Easing
cubic_interpolate — Smooth Path Following
Interpolation Comparison
| Function | Speed | Reaches Target | Smooth | Use For | |
|---|---|---|---|---|---|
lerp(a, b, t) | Variable | Only at t=1 | Yes | UI transitions, blending | |
move_toward() | Constant | Yes | No | Movement, timers | |
slerp() | Variable | Only at t=1 | Yes | Rotation blending | |
smoothstep() | S-curve | Soft threshold | Yes | Fog, volume, thresholds | |
cubic_interpolate() | Variable | Only at t=1 | Very | Paths, camera rails |
4. Curves and Paths
Curve resource for value-over-time (e.g., damage falloff curves). Path2D / Path3D for spatial paths sampled by PathFollow2D / PathFollow3D — use for moving platforms, missile guidance, camera rails.
See references/curves-and-paths.md forCurvesetup, Path nodes, PathFollow properties.
5. Random Number Generation
Global functions (randf(), randi() % N, randf_range(a, b)) for one-shot randomness. RandomNumberGenerator for seeded, reproducible randomness (procgen, replay, save-state). Weighted selection via cumulative-sum or alias method.
See references/random-numbers.md for full GDScript on each pattern, plusFastNoiseLitefor procedural generation noise.
6. Common Game Math Recipes
Five recipes: look at target (2D Vector2.angle_to_point), orbit around a point (polar coordinates), sine-wave bob (floating UI elements, treasure), angle wrapping (-PI..PI canonicalization), clamped approach with deadzone (analog input + small-input ignore).
See references/game-math-recipes.md for ready-to-use code on each recipe.
7. Common Pitfalls
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/math-essentials/SKILL.md
Popularity
- Repository stars
- 354
- Repository forks
- 18
- 7-day trend score
- 29
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/jame581/godotprompter/math-essentials)