wlm24 (at) drexel (dot) edu |
 
Lesson: Using 3DGameStudio Player and AI Entities

Adding a Playable Character

First and foremost, save your level.

Game scripts are added through the Project Manager.

The first time you run the Project Manager, you will be presented with the following dialog box:

For base functionality, choose A6_template_project. This only adds two required scripts to your project: gid01.wdl (global identifiers required for entities) and display00.wdl (creates the display screen).

Once you select your template, you will see the project manager. Click on the "Add" tab. The frame on the right lists all scripts that are currently loaded in the project, and unloaded scripts can be found in the dropdown in the upper left, with descriptions of the script below.

Select "Biped Player (01)" from the drop down menu and press the [Add Script-=>>] button. In addition to the Biped player script, you should see seven other scripts added as well. These are all dependencies that are required by the Biped player script.

Close the project manager.

Now add a character entity to your scene by selecting Object > Load Entity. I selected the wizard.

Right-click on the character, and select "Behavior". Select PlBiped01 from the dialog window:

You will also need an entry point for your character. Add a position indicator (Object > Add Position) and orient it where you what your player to start.

Now build your level and run it .

There is a problem! You can move the character around with the WASD keys, but the camera is not moving with him. We simply must add a new script to fix this problem. Return to your project manager, and, under the "Add" tab, add the following scripts: "3rd Person Camera" and "First Person Camera".

Now build your level and run it again. You will see that the camera is now a first person viewpoint. You can switch to 3rd person view by pressing [F7]. As with any script, you can always remove its functionality by removing it in the Project Manager.

Now feel free to explore as a character!

Adding Enemies

While this is pretty cool , a level is boring without enemies. Let's add some.

Load another character entity. I selected the witch. Now, open your project manager and add the "Dumb AI Bipeds (01)" script. Close the project manager. Now, right-clicking your enemy character, select Behavior, and choose "AIDumbBiped01" from the action list.

Now build and run your level. The enemy won't do too much; it'll walk straight towards a wall and stop. It won't even notice you. Dumb AI entities are mainly used for testing. We want something a little more vicious.

In the project manager, add "fxa (01)" and "Simple FPS AIs (01)". Close the project manager, and, right-clicking on your character, select "Properties". Under the "Behaviour" tab, click the "Choose Action" button.

From the available list, select "AIFPS01_Guard". Now run the level again. As you approach the enemy, it should notice you and start attacking you. Looks like we need a way to defend ourselves.

In the project manager, add "Biped Player Weapons (00)". Build and run. When you enter the level, press the [e] key. You can now cycle through three available weapons. Blow that sucker away.

If you are having trouble, my source files are here (be sure to unzip the files to your 3DGS work directory). Happy hunting!