Barriers Spline
The incorporation of barriers and spline in our Red Riding Hood Game
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 ImplementationWaypoints: 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!
- Level 2: The Chase
Red Riding has to successfully follow the path to her grandma’s house, without colliding with the wolf
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.