Presentation is loading. Please wait.

Presentation is loading. Please wait.

Problem Solving Methodology Rachel Gauci. Problem Solving Methodology Development Design Analysis Evaluation Solution requirements and constraints. Scope.

Similar presentations


Presentation on theme: "Problem Solving Methodology Rachel Gauci. Problem Solving Methodology Development Design Analysis Evaluation Solution requirements and constraints. Scope."— Presentation transcript:

1 Problem Solving Methodology Rachel Gauci

2 Problem Solving Methodology Development Design Analysis Evaluation Solution requirements and constraints. Scope of the solution Solution design (IPO CHART, PSEUDOCODE ETC.) Create the code Testing (DEBUGGING- TESTING TABLES) Report Document When an information problem exists, a structured plan is followed to ensure that the most appropriate solution is found and implemented. In ICT the structured plan is the problem solving methodology.

3 CODING IN UNITY

4 ‘Hello World’ script #pragma strict function Start() { Debug.Log (“Hello”); Debug.Log (“My name is Rachel”) Debug.Log (“Welcome to Javascript in Unity”) } Function Update () { } TASK: 1.Open Unity 2.Create a new project 3.Add in an empty object (GameObject -> create empty) 4.Add a new javascript and name it HelloWorld (right click on assets folder -> create-> Javascript) 5.Open the script and type in the following to MonoDevlop and click save 6.Back in Unity press play and watch what happens.

5 Adding 2 numbers (Math's) # pragma strict Var num1 : int = 3; Var num2 : int = 4; Var num3 : int; Function Start () { Debug.Log (“Number 1 =” +num1); Debug.Log (“Number 2 = ” +num2); Num3 = num1 + num2; Debug.Log (“Number 1 + Number 2 =” +num3); } TASK: 1.Right click on your assets folder, create -> a new Javascript and name it AddNumbers. 2.Open the script in MonoDevelop and type in the following code. 3.Click save and return to Unity. 4.Create a new scene (file-> new scene) 5.Create an empty object (GameObject -> create new) 6.Attach the script to the object 7.Press play

6 Movement (Rotation) #pragma strict var variableRotationRate = 0.0f; var fixedRotationRate = 0.0f; function Update () { transform.Rotate (Vector3.up * Time.deltaTime * (variableRotationRate * 360.0f )); } function FixedUpdate () { transform.Rotate (Vector3.up * Time.deltaTime * (fixedRotationRate * 360.0f )); }

7 TASK 1.Create a new scene 2.Insert 2x cubes (GameObject -> create other -> cube) 3.Ensure the cubes are not overlapping (in the scene view move the cubes in a particular position) 4.Create a new JavaScript, open MonoDevelop and paste the code from my website in. (this code is in my SAC preparation page) 5.Click save 6.Return to Unity and check the console for any errors, fix them 7.Attach the script to the 2 cubes and press play, what happens? 8.Now stop play and tweak the rotation rate to 0.25 and its fixed rotation rate to 0 for one for the cubes. for the second cube set the rotation rate to 0 and the fixed rotation rate to 0.25. press play and see the difference. (This is done by selecting the cube/sphere, then in the inspector view look at the script’s variables are available for change

8 GUI WHAT IS GUI? A graphical user interface (GUI) is a human-computer interface (i.e., a way for humans to interact with computers) Unity GUI allows you to create a wide variety of highly functional GUIs very quickly and easily. Rather than creating a GUI object, manually positioning it, and then writing a script that handles its functionality, you can do everything at once with just a few lines of code. The code produces GUI controls that are instantiated, positioned and handled with a single function call.

9 Example #pragma strict var heightArray = new Array(); var userInput : String; var arrInfo : String; var displayText: String; //-------------------------------------------------------------- // Shows GUI elements (buttons, input) //-------------------------------------------------------------- function OnGUI() { //[Input] 'Add Element' user input userInput = GUI.TextField(Rect(10, 10, 200, 50), userInput, 25); //[Button] Add Button if(GUI.Button(Rect(220,10,150,50),"Add Height in CM's")){ heightArray.Push(userInput); userInput = ""; } //-------------------------------------------------------------------------------- //[Loop] create a display text of all the heights... var arrElements = ""; for(var i: int = 0; i < heightArray.length ; i++) { arrElements += heightArray[i] + ", "; } //[Variable] arrInfo = "Count: "+ heightArray.length.ToString() + "\n Heights: " + arrElements; //[Display] Middle Information Box GUI.Box(Rect(10, 80, 400, 50),arrInfo); }

10 INSTANTIATE WATCH: http://unity3d.com/learn/tutorials/modules/beginner/scri pting/instantiate http://unity3d.com/learn/tutorials/modules/beginner/scri pting/instantiate http://unity3d.com/learn/tutorials/modules/beginner/scri pting/instantiate


Download ppt "Problem Solving Methodology Rachel Gauci. Problem Solving Methodology Development Design Analysis Evaluation Solution requirements and constraints. Scope."

Similar presentations


Ads by Google