Vous êtes sur la page 1sur 3

DGH1 Assignment Oisin Bourke README: 1. 2. 3. 4. 5. 6. 7.

Start Screen/Menu Scene and terrain setup Input methods and script Animations and Gravity Camera movement Collision detection, triggers. Instantiating an object at run time, cloning and destroying an object.

1. Start Screen/Menu ---------------------- Created a scene for both the start menu and the main game area. - Created a custom background in Photoshop and imported it into unity, a firebal l is visible on the image as "fireball" objects will be insatiated in my scene. - Created a GUITexture with my image selected and positioned it correctly. - To create a play button I first went to Build Settings and connected the scene s, then created a Javascript named "MainMenu1" - MainMenu1.js has three main variables, mainmenuSkin, areaWidth and areaHeight. The first is for storing custom skins, the later two are for the dimensions. GU ILayout.BeginArea creates the container for my buttons. -The GUILayout.Button statements give me my Play and Quit Button. - Attached the script to a new empty gameobject which will act as initator , - Used GuiSkin to attach alternating textures to buttons. 2. Scene and terrain setup ---------------------- For the main game scene I have created a basic terrain with a directional ligh t and a main camera. - A base texture was applied to the terrain and a skybox was imported. - A character was imported with three animation cycles: Idle, Walk and run. - Input settings were modified to remove defaults. 3. Input methods and script ---------------------- A basic script named "PlayerCharacter.js" was created and attached to the char acter. - This script contains variables for movement speed, gravity, move direction (ve ctor3) and a character controller. - This script allows for basic movement and turning

- The characters animation sequences were set in the characters FBX Importer sec tion in the inspector. 4. Animations and Gravity ---------------------- The "PlayerCharacter.js" script was modified primarily to include the three an imations, allowing them to run when the character turns or moves. - We also modify the gravity variable to make it useful, multiplying the gravity value by the time and then subtracting from the moveDirection's Y component (causing accelera tion).

5. Camera movement ---------------------- The "Smooth Follow" Camera control is applied to the Main Camera, the target i s set to the character. - After testing different configuration with this method I created a new script called "CameraController.js" with the aim of allowing a zoom in and out feature for the camera, using Quaternions to keep the camera distance. - The input settings are modified to allow a "CameraZoomIn" and "CameraZoomOut" button. - Making the camera a child of the character seefms to be the most simple method of achieving what I wanted. 6. Collision detection, triggers. ---------------------- In this scene I have an OnTriggerEnter area that activates a trapdoor on a sta ck of barrels with rigidbodies that are affected by gravity. - A "DoorOpenScript.js" is created for this purpose with a Boolean to check if t he trap is open, an OnTriggerEnter function will activate if a collider passes through it. - Each of the barrels in this scene has a rigidbody attached to it, a mass of 1 and is using gravity. So not only will the barrels fall on top of each other when released, they can a lso be pushed aside by other objects including the character and the fireball in the next sect ion. - In the PlayerCharacter.js script an OnControllerColliderHit function is added

(push strength of 10 for the object, 4 for the player).

7. Instantiating an object at run time, cloning and destroying an object. ---------------------- My first instantated object (a cube) will appear at runtime, as soon as the sc ene is played. - I made an empty game object and attached a new script (InstantiateScript.js) t o it. - The function in this script is set to run before any Update(), a gameobject va riable will be created. The rest of the script simply describes the position and scale in Vector3 - For my cloning with the instantiate function I thought it would be nice to hav e a kind of fireball to shoot at the various rigidbodies in my scene. So I creat ed a sphere, gave it a firey texture and attached a fireball sound effect. - A seperate prefab was created for this sphere and the sphere object was linked to it.\ - The following changes were made to the PlayerCharacter.js script: I added a ne w game object var called mySphere with can then be seen in the Inspector menu. T he original sphere object is then linked to this var in the menu. - In the code, once a button is pressed the gameobject variable is called (the s phere). Another button destroys - A constant force, relative force of 60 on the z access makes the sphere fly aw ay in the direction the player is facing, this is our fireball.

Vous aimerez peut-être aussi