Getting organized

Since we are writing several scripts, we should stay organized. We can click Favorites | All Scripts in the Project panel to get a list of all the scripts in our project, but there are a lot of them, most of which we will not edit for our game. So, let's create a folder in the Project panel to organize our custom scripts. Here are the steps: 

  1. In the Project panel, right-click the Assets folder
  2. Select Create | Folder
  3. Name the new folder Custom Scripts

Now that we have a folder for our custom scripts, let's move a few: 

  1. In the Project panel, click Favorites | All Scripts
  2. Scroll until you find the BeetleNPC script we created earlier in this chapter.
  3. Drag the BeetleNPC script to our Custom Scripts folder. This moves the BeetleNPC script to the designated folder. You will still see it in Favorites | All Scripts because this feature shows all scripts regardless of their location.
  4. Move the CameraFollower script to the Custom Scripts folder.
  5. Move the PlayerController script to the Custom Scripts folder.
  6. Move the PlayerMotor script to the Custom Scripts folder.

When you are done moving scripts, your Cucumber Scripts folder should be the same as the following screenshot:

Our beetles will have the following behaviors in our game:

  • Search for cucumbers (patrol)
  • Eat cucumbers when found
  • Defend itself from the Cucumber Man on the ground
  • Stand to defend itself from the Cucumber Man

The next sections will show you how to script these behaviors.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset