Math · 2021 · Prototype
Vector Math Experiments
Three small Unity sketches in game maths covering dot-product sight checks, a ray that bounces off surfaces, and a cross-product coordinate system.

Pieces03

Seeing with the dot product
Detects when the player is looking at something by comparing the view direction with the direction to the object.

Bouncy ray
A ray that bounces off multiple surfaces, with each bounce worked out using the dot product.

Cross-product coordinate system
A full coordinate system built from cross products — each axis perpendicular to the other two.
Overview
Short Unity sketches where I practised the vector maths behind my games, mostly the dot and cross products, visualised with editor gizmos so I could see each result as I moved things around.
What I built
- Seeing with the dot product. This detects when the player is looking at something by comparing the view direction with the direction to the object. The same idea drives the scarecrow and item pickup in Scarecrow: Don't Look Away.
- Bouncy ray. A ray that bounces off multiple surfaces, with each bounce worked out using the dot product. The loop at the top of the page shows it rebounding between two walls as its origin rotates.
- Cross-product coordinate system. Building a full coordinate system from cross products, since the cross product of two vectors is perpendicular to both. The same tool picks the turning direction for the zombies in Zombie Killer and the collector in Flag Collector.