Game math: choose the right operation
Directions, coordinates, planes, smooth motion, randomness and paths: a task-based route.
Map the task to an operation
| Task | Use | Guide |
|---|---|---|
| Aim toward a target | Target − origin; normalize when needed | Vectors |
| Test a side or project onto a plane | A normal, Plane.DistanceTo, Project | Planes |
| Convert a local point to world space | Transform × point, ToGlobal/ToLocal | Transforms |
| Approach smoothly or move at a specified speed | Time-weighted Lerp or MoveToward | Interpolation |
| Replay generation or resume a sequence | RandomNumberGenerator.Seed/State | Random numbers |
| Follow a route | Curve2D, Path2D, PathFollow2D | Curves and paths |
| Rotate a 3D object and understand parent scale | Entity3D, Basis, Quaternion | 3D transforms |
Vector2/Vector3 hold numbers; you give them meaning: position, direction, velocity or normal. Position (10, 0) is a point; velocity (10, 0) is displacement per second. Sharing a type does not make these quantities interchangeable.
Reckfell conventions
Ordinary 2D uses X right and Y down. In 3D, Y points up and the standard forward direction is −Z. Rotation methods and Rotation use radians; RotationDegrees is for degrees. Vector3.One is not a unit direction: its length is √3.
An operation's operands must use matching spaces and units. Subtracting a player's local position from a target's world position does not produce a valid aim direction. Multiply speed by timestep once. Geometric plane projection does not replace a physics collision query.
Check understanding
Start with the example relevant to your task. Each specifies its root type, complete C# file and expected result. Images come from these examples on Windows 1.0.0, with RU/EN captions. Checks establish math conventions and engine object behavior, not physics simulation, performance or identical bits on every platform.
Compare floats with a tolerance appropriate to the task's scale. IsFinite rejects NaN/infinity but does not establish matrix invertibility or a unit normal. Check an operation's prerequisites before its result.