Index of every page on this site: llms.txt
All skills
jame581 avatar

/math-essentials

@426e8ab
by Jan Mesarčjame581/godotprompter979 stars
63
Run it yourself

Use when implementing game math — vectors, transforms, interpolation, curves, random number generation, and common geometric recipes

Use this Skill: https://skilld.dev/gh/jame581/godotprompter/math-essentials

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesgame-math-recipes.md

≈682 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Common Game Math Recipes

Reference for skills/math-essentials/SKILL.md — look-at target (2D), orbit around a point, sine-wave bob (floating), angle wrapping, clamped approach with deadzone.

← Back to SKILL.md


6. Common Game Math Recipes

Look At Target (2D)

# Instant look-at
rotation = global_position.angle_to_point(target.global_position)

# Smooth rotation toward target
var target_angle: float = global_position.angle_to_point(target.global_position)
rotation = lerp_angle(rotation, target_angle, 10.0 * delta)
Rotation = GlobalPosition.AngleToPoint(target.GlobalPosition);

float targetAngle = GlobalPosition.AngleToPoint(target.GlobalPosition);
Rotation = Mathf.LerpAngle(Rotation, targetAngle, 10.0f * (float)delta);

Orbit Around a Point

func _process(delta: float) -> void:
    var angle: float = Time.get_ticks_msec() / 1000.0 * orbit_speed
    position = center + Vector2(cos(angle), sin(angle)) * orbit_radius
public override void _Process(double delta)
{
    float angle = Time.GetTicksMsec() / 1000.0f * orbitSpeed;
    Position = center + new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)) * orbitRadius;
}

Sine Wave Bob (Floating Effect)

var _base_y: float

func _ready() -> void:
    _base_y = position.y

func _process(delta: float) -> void:
    position.y = _base_y + sin(Time.get_ticks_msec() / 1000.0 * bob_speed) * bob_amplitude
private float _baseY;

public override void _Ready() => _baseY = Position.Y;

public override void _Process(double delta)
{
    Vector2 pos = Position;
    pos.Y = _baseY + Mathf.Sin(Time.GetTicksMsec() / 1000.0f * bobSpeed) * bobAmplitude;
    Position = pos;
}

Angle Wrapping

# Wrap angle to -PI..PI range
var wrapped: float = wrapf(angle, -PI, PI)

# Shortest rotation direction between two angles
var diff: float = angle_difference(current_angle, target_angle)
# Returns the shortest path, accounting for wrapping

# Lerp angles correctly (handles wrapping)
rotation = lerp_angle(rotation, target_rotation, 5.0 * delta)
float wrapped = Mathf.Wrap(angle, -Mathf.Pi, Mathf.Pi);
float diff = Mathf.AngleDifference(currentAngle, targetAngle);
Rotation = Mathf.LerpAngle(Rotation, targetRotation, 5.0f * (float)delta);

Clamped Approach with Deadzone

# Move toward target but stop within a deadzone
func approach_with_deadzone(current: Vector2, target: Vector2, speed: float, deadzone: float, delta: float) -> Vector2:
    var dist: float = current.distance_to(target)
    if dist <= deadzone:
        return current
    return current.move_toward(target, speed * delta)

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts29d3 checks · Risk SAFE
  • Gen Agent Trust Hub29d

    The skill provides comprehensive documentation and code examples for game-related mathematics in Godot 4.3+, including vectors, transforms, and interpolation. No security issues or malicious patterns were detected.

  • Socket29d

    No alerts

  • Snyk29d

    Risk: LOW · No issues

Signed by skilld at 426e8ab. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 6 days ago.

Activeupdated last month

README badge

README badge for jame581/godotprompter/math-essentials