CSCI 5895: 3D Graphics and Animation

Total Page:16

File Type:pdf, Size:1020Kb

CSCI 5895: 3D Graphics and Animation

CSCI 5838: 3D Graphics and Animation Assignment 4: Scripting a Simple First-Person Game Due Wednesday, October 28

Introduction

In this assignment, you will create a very simple first person game in Unity using the characters you created in the previous assignments. Specifically,  Your robot character will “chase” the player.  Your treasure character will “run away” from the player.

Creating a World in Unity

The first thing you should do is to create a simple “world” for your game to take place in using the Unity built-in objects. This will include:

 A plane that will be the “surface” of the world. You should resize it to make it large.  A set of shapes (cubes, spheres, cylinders, etc.) distributed around the plane. These will add interest to your world, and to act as “obstacles” for the player and robot.  You should also consider using stretched cubes to put “walls” at the edges of your plane to prevent users from “falling off” the edge of the world.

Importing your Characters

You will need to import your robot and player characters from Blender. As a reminder, this involves:  Removing all other objects from the scene in Blender (including the camera and lamp) before you save it.  Copying all image files your characters use into the Assets folder of your Unity project (do this first).  Copying the .blend files for your characters into the Assets folder of your Unity project.

Adding a First-Person Player

Add a first-person player into your world, using the script I have created and posted on the site. Specifically:  Create a new script and paste my code into it.  Drag the camera to the place in the scene where you want the player to start at.  Add a CharacterController to it by going to Compnent  Physics and selecting CharacterController.  Drag the script onto the camera object.

Scripting the Robot

Add a script (that will be used by your robot) that moves the object towards the first- person camera object representing the player.  Don’t forget that you will need to add a tag to the player object, so the script can access the GameObject representing the player object in order to find its location and move towards it.  This script will probably look very much like the “chase” script I introduced in class, which you can feel free to use as a basis for yours.  Note that you just have to make the robot move towards the player – you do not need to make it “face” the player (at least on this assignment).  You should also make your robot a Rigidbody (otherwise, it will run right through the obstacles that you have set up!)

Scripting the Treasure

Add a script (that will be used by your treasure) that moves the object away from the first-person camera object representing the player.

This will be the main “creative” aspect to this assignment. If it simply always moves directly away from the player, you will receive a 45/50. To get full credit, it will need to present more of a challenge. Things you could try might include:  Adding some “randomness” to the movement of the treasure.  Speeding up when the player gets near.  Using “obstacles” (such as trying to keep a specific obstacle between itself and the player).  Using the robot for “protection” by moving towards it as well as away from the player.

What to Turn In

Because of the size of the Unity projects, you will not email the entire project to me. Instead, I will give you time at the end of class to demonstrate your project to me.

The one thing that I am requiring is to email me the scripts for your robot and treasure to me at [email protected]. As always, make sure that your scripts are well documented (particularly with respect to how the treasure object avoids the player).

Recommended publications