© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2024
C. HardmanGame Programming with Unity and C#https://doi.org/10.1007/978-1-4842-9720-9_19

19. Wandering Hazards

Casey Hardman1  
(1)
West Palm Beach, FL, USA
 

In this chapter, we’ll implement an obstacle type that we’ll call Wanderer. They’ll look like the Patrollers we implemented in the last chapter, but instead of moving along a set of points repeatedly, they’ll be confined to a rectangular region, and they’ll periodically wander over to a new point inside that region. We can put multiple Wanderers in the same region, and they’ll all act separately, finding a new place to move to every so often. We’ll use a little bit of random number generation to make them ...

Get Game Programming with Unity and C#: A Complete Beginner’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.