Level 2: Spline & Waypoint Navigation
Goal: To restrict Red Riding Hood’s movement to a specific curved wooden path using a Spline system, preventing the player from wandering into out-of-bounds areas.
Technical Implementation
Waypoints: We defined an array of (x, y) coordinates that follow the center of the wooden path.
Spline Logic: The character calculates the distance to the nearest waypoint and “snaps” or lerps (Linearly Interpolates) toward the line connecting the current and next waypoint.
Barriers: Instead of invisible walls everywhere, the path itself acts as the “allow list” for movement.
The Red Riding Hood Game
Our game is Red Riding Hood
The game consists of two levels!
FULL GAME:
Level 1: Red Riding has to collect coins as tokens
Level 2: The Chase
Red Riding is being chased by the wolf down a path and has to escape to her grandma’s
Level 3: Red Riding has to shoot and kill the big wolf in her grandma’s house
Level 4: Red Riding has to shoot as many wolves possible within a time limit
What is a spline?
A spline is a smooth curved line made from points.
Instead of straight lines:
⬛⬛⬛⬛
We get smooth paths
We use splines because:
- Smooth movement paths
- Easy safe-zone control
- Simple boundary system
- Less complex collision math
Splines in Our Levels
In our game:
- Left spline = boundary wall
- Right spline = boundary wall
- Player = must stay inside
So the level becomes a safe forest path.
REAL WORLD EXAMPLE
The Mathematics & Calculus Behind Our Splines
You don’t need a math degree to use splines, but understanding the math makes them very powerful! Here is how math creates our path:
-
Piecewise Polynomials (The “Curve” Part)
Instead of one massive, complex formula for the whole path, we use piecewise polynomial functions. This means we use small, simple curves (splines) that connect smoothly together, like links in a chain.
-
Calculus: Minimum Curvature
Splines are designed to find the smoothest path. They use calculus to minimize the “bending energy”—essentially minimizing the second derivative of the curve.