Robot Panic Behavior

Christiane Snyder

We want to make the small robots in the scene run from place to place as if they are panicked. To make this possible, create a “PanicBehavior” script and attach it to the “RunningRobot” prefab as a component.

Even though we’ll eventually want these tiny robots to run around randomly on the streets, we’ll simplify this concept for now and start by making our panicked robot move just from two way points.

Drag a “Running Robot” prefab into the scene. When you hit “Play”, it should run back and forth between the same two points. This is way too easy to hit with the lasers.

To make it more random, we’ll link in the “MapNav” GameObject that was included in the starter package. This empty object has a script called “MapInfo” that generates a grid system off of provided parameter fields (dont worry about inputing values into the MapInfo script, they are already entered for this lesson). A NPC can get its next way point by calling “GetNext()” on an reference to “MapInfo”.

Update PanicBehavior so that it interacts with the values returned by “MapNav”: