Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Practical C++ Game Programming with Data Structures and Algorithms

You're reading from   Practical C++ Game Programming with Data Structures and Algorithms Write high-performance code and solve game development challenges with expert-led C++ solutions

Arrow left icon
Product type Paperback
Published in Jun 2025
Publisher Packt
ISBN-13 9781835889862
Length 408 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Authors (2):
Arrow left icon
Zhenyu George Li Zhenyu George Li
Author Profile Icon Zhenyu George Li
Zhenyu George Li
Charles Shih-I Yeh Charles Shih-I Yeh
Author Profile Icon Charles Shih-I Yeh
Charles Shih-I Yeh
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Part 1: Data Structure and Algorithm Fundamentals
2. Gearing Up: C++ for Game Development FREE CHAPTER 3. Data Structures in Action: Building Game Functionality 4. Algorithms Commonly Utilized in Game Development 5. Part 2: Graphics Algorithms in Practice
6. 2D Rendering and Effects 7. The Camera and Camera Controls 8. 3D Graphics Rendering 9. Rendering a 3D Game World 10. Part 3: Breathing Life into Your Games
11. Animating Your Characters 12. Building AI Opponents 13. Machine Learning Algorithms for Game AI 14. Part 4: Reflecting and Moving Forward
15. Continuing Your Learning Journey 16. Other Books You May Enjoy
17. Index

Steering for movement

Steering behaviors are widely used in games to manage the dynamic and smooth movement of characters, such as NPCs or vehicles. Typical steering behaviors include tasks such as seeking, fleeing, arriving, and wandering, where an AI character adapts its movement based on environmental factors or specific objectives.

To better understand how steering controls an NPC’s movement and maneuvering, we use Figure 9.5 to illustrate an example of an NPC avoiding overlapping with the player character:

Figure 9.5 – An NPC steering move example

Figure 9.5 – An NPC steering move example

Let’s understand what’s going on in Figure 9.5, as follows:

  1. a: Both the player and the NPC are moving at speeds Vp and Vn, respectively, and their paths intersect, leading to a potential collision.
  2. b: When the player and NPC come close enough to block each other’s movement, a push-away velocity (Vpush) is applied to the NPC to resolve the obstruction.
  3. c: The...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime