CHAPTER 03
Intermediate
Movement and Motion Systems
Updated: May 16, 2026
20 min read
# CHAPTER 3
Movement and Motion Systems
1. Introduction
A static world is a boring world. The foundation of any interactive game is motion—moving an object from point A to point B smoothly and predictably. However, raw mathematical translation is not enough. If you simply teleport an object 5 pixels every frame, the movement will appear jittery on some monitors and incredibly fast on others. In this chapter, we will master Movement and Motion Systems. We will learn how to apply linear movement using directional vectors, calculate exact speeds, and ensure flawless, buttery-smooth motion across all hardware using Delta Time.2. Learning Objectives
By the end of this chapter, you will be able to:- Implement basic linear motion (Kinematics) in code.
- Combine Input Axes to generate a movement vector.
- Prevent diagonal speed exploits using Vector Normalization.
-
Understand the critical role of
DeltaTimein frame-rate independent motion.
- Program smooth, interpolated movement transitions.
3. Linear Movement (Kinematics)
The simplest form of physics movement is Kinematic motion. This means we are moving the object using explicit math code, rather than letting a physics engine push it with forces.-
The formula is always:
Position = Position + (Direction * Speed * Time)
4. Constructing the Movement Vector
In a 3D game, you generally read player input to determine direction.-
Input X(A/D keys) gives a value between -1 and 1.
-
Input Z(W/S keys) gives a value between -1 and 1.
Vector3(x, 0, z).
csharp
5. The Diagonal Exploit (Normalization)
If the player holds 'W' (Forward: 1) and 'D' (Right: 1), the resulting vector is(1, 0, 1).
According to the Pythagorean theorem, the length (magnitude) of this diagonal vector is 1.41.
- The Bug: This means the player runs 41% faster when running diagonally! This was a famous exploit in early 90s games (like *GoldenEye 007*).
-
The Fix: You must always call
moveDirection.Normalize(). This forces the maximum length of the vector to be exactly1.0, capping diagonal speed.
6. Frame-Rate Independence (Delta Time)
If you runposition += direction * speed inside the Game Loop, it happens every frame.
- At 60 FPS, it runs 60 times.
- At 144 FPS, it runs 144 times. The player moves more than twice as fast!
Time.deltaTime) is the fraction of a second it took to render the last frame. By multiplying your movement by Delta Time, you convert the math from "pixels per frame" to "meters per real-world second."
csharp
7. Visual Learning: The Motion Formula
txt
8. Best Practices
-
Use GetAxisRaw for Snappy Input: If you use standard
GetAxis(), engines usually apply a slight "smoothing" filter to make the input feel like an analog stick, causing a slight delay before reaching top speed. For tight, responsive platformers (like *Celeste*), useGetAxisRaw(), which snaps instantly to1or0.
9. Common Mistakes
- Multiplying DeltaTime Twice: Beginners sometimes multiply their acceleration by DeltaTime, and then multiply the resulting velocity by DeltaTime again. This creates a quadratic time curve, making the physics simulation behave wildly unpredictably when framerates fluctuate. Only multiply velocity by DeltaTime when adding it to the position!
10. Mini Project: Build a Smooth Kinematic Controller
Objective: Write a complete, optimized character movement script.
csharp
11. Practice Exercises
- 1. Write the core formula for calculating Kinematic movement over time.
-
2.
Why is it critical to multiply movement speed by the engine's
DeltaTimevariable?
12. MCQs with Answers
Question 1
In a top-down game, the player holds both the "Up" and "Right" arrow keys simultaneously. If the programmer forgets to normalize the movement vector, what gameplay bug will occur?
Question 2
Multiplying a character's velocity by Time.deltaTime changes the speed calculation from "units per frame" to what standard measurement?
13. Interview Questions
- Q: Explain the mathematical "Diagonal Exploit" found in early 3D games. How do modern engines prevent this issue using Vector Normalization?
-
Q: Walk me through the concept of frame-rate independence. Why does multiplying velocity by
DeltaTimeguarantee that a character moves at the exact same speed on both a 30 FPS console and a 144 FPS PC?
-
Q: What is the difference between Kinematic motion (updating
transform.positionvia script) and Dynamic motion (using a physics engine's Rigidbody)? When is it appropriate to use Kinematic motion?
14. FAQs
Q: Can I use Kinematic movement if I have walls in my game? A: If you forcefully updatetransform.position directly into a wall, the physics engine will glitch, and you might teleport through the wall! For Kinematic characters, you must use special collision-checking functions (like Unity's CharacterController.Move()) to stop the character before they intersect solid geometry.
15. Summary
In Chapter 3, we put our game in motion. We utilized the core Kinematic formula:Direction * Speed * Time. We read player input to construct 3D Vectors, and clamped their magnitude using Normalization to prevent the infamous diagonal speed exploit. Crucially, we decoupled our game speed from the computer's CPU speed by injecting DeltaTime into our math, ensuring flawless, professional-grade movement on any hardware.