Wandering Hazards
摘要
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 wait some amount of time between a minimum and maximum number of seconds before moving again, which we can configure in the Inspector.