ΣΕΧΝΟΛΟΓΙΚΟ ΠΑΝΕΠΙΣΗΜΙΟ ΚΤΠΡΟΤ ΣΜΗΜΑ ΠΟΛΤΜΕΩΝ ΚΑΙ ΓΡΑΦΙΚΩΝ ΣΕΧΝΩΝ



Σχετικά έγγραφα
3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

2 Composition. Invertible Mappings

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

Section 8.3 Trigonometric Equations

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Οδηγίες Αγοράς Ηλεκτρονικού Βιβλίου Instructions for Buying an ebook

How to register an account with the Hellenic Community of Sheffield.

SPEEDO AQUABEAT. Specially Designed for Aquatic Athletes and Active People

9.09. # 1. Area inside the oval limaçon r = cos θ. To graph, start with θ = 0 so r = 6. Compute dr

CYTA Cloud Server Set Up Instructions

Πώς θα σχεδιάζατε τα αντικείμενα στη σκηνή;

Δημιουργία Λογαριασμού Διαχείρισης Business Telephony Create a Management Account for Business Telephony

Instruction Execution Times

The Simply Typed Lambda Calculus

«Εικονικοί κόσµοι και καλλιτεχνική δηµιουργία».

Εγκατάσταση λογισμικού και αναβάθμιση συσκευής Device software installation and software upgrade

Partial Trace and Partial Transpose

Galatia SIL Keyboard Information

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

VBA ΣΤΟ WORD. 1. Συχνά, όταν ήθελα να δώσω ένα φυλλάδιο εργασίας με ασκήσεις στους μαθητές έκανα το εξής: Version ΗΜΙΤΕΛΗΣ!!!!

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

Modbus basic setup notes for IO-Link AL1xxx Master Block

Capacitors - Capacitance, Charge and Potential Difference

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

ΑΛΛΗΛΕΠΙΔΡΑΣΗ ΑΝΘΡΩΠΟΥ - ΥΠΟΛΟΓΙΣΤΗ. Διδάσκων: Κωνσταντίνος Στεφανίδης

Section 9.2 Polar Equations and Graphs

PortSip Softphone. Ελληνικά Ι English 1/20

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

Homework 3 Solutions

EE512: Error Control Coding

The challenges of non-stable predicates

Concrete Mathematics Exercises from 30 September 2016

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

SOAP API. Table of Contents

Συστήματα Διαχείρισης Βάσεων Δεδομένων

Example Sheet 3 Solutions

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Section 7.6 Double and Half Angle Formulas

6.1. Dirac Equation. Hamiltonian. Dirac Eq.

Approximation of distance between locations on earth given by latitude and longitude

department listing department name αχχουντσ ϕανε βαλικτ δδσϕηασδδη σδηφγ ασκϕηλκ τεχηνιχαλ αλαν ϕουν διξ τεχηνιχαλ ϕοην µαριανι

Στο εστιατόριο «ToDokimasesPrinToBgaleisStonKosmo?» έξω από τους δακτυλίους του Κρόνου, οι παραγγελίες γίνονται ηλεκτρονικά.

Finite Field Problems: Solutions

TMA4115 Matematikk 3

Assalamu `alaikum wr. wb.

derivation of the Laplacian from rectangular to spherical coordinates

b. Use the parametrization from (a) to compute the area of S a as S a ds. Be sure to substitute for ds!

Εργαστήριο 9. Styling with Javascript

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =?

4.6 Autoregressive Moving Average Model ARMA(1,1)

Calculating the propagation delay of coaxial cable

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

LESSON 14 (ΜΑΘΗΜΑ ΔΕΚΑΤΕΣΣΕΡΑ) REF : 202/057/34-ADV. 18 February 2014

Other Test Constructions: Likelihood Ratio & Bayes Tests

[1] P Q. Fig. 3.1

Srednicki Chapter 55

( ) 2 and compare to M.

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

Second Order RLC Filters

14 Lesson 2: The Omega Verb - Present Tense

Review Test 3. MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Areas and Lengths in Polar Coordinates

Solutions to Exercise Sheet 5

Απόκριση σε Μοναδιαία Ωστική Δύναμη (Unit Impulse) Απόκριση σε Δυνάμεις Αυθαίρετα Μεταβαλλόμενες με το Χρόνο. Απόστολος Σ.

Statistical Inference I Locally most powerful tests

ST5224: Advanced Statistical Theory II

Areas and Lengths in Polar Coordinates

C.S. 430 Assignment 6, Sample Solutions

The municipality of Apokoronas has created a new app for your smart phone.

Right Rear Door. Let's now finish the door hinge saga with the right rear door

Math 6 SL Probability Distributions Practice Test Mark Scheme

Scratch Διδακτική του Προγραμματισμού. Παλαιγεωργίου Γιώργος

Βασικές εισαγωγικές έννοιες

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 5: Component Adaptation Environment (COPE)

Strain gauge and rosettes

Potential Dividers. 46 minutes. 46 marks. Page 1 of 11

Solutions to the Schrodinger equation atomic orbitals. Ψ 1 s Ψ 2 s Ψ 2 px Ψ 2 py Ψ 2 pz

UNIVERSITY OF CALIFORNIA. EECS 150 Fall ) You are implementing an 4:1 Multiplexer that has the following specifications:

Special edition of the Technical Chamber of Greece on Video Conference Services on the Internet, 2000 NUTWBCAM

Οι αδελφοί Montgolfier: Ψηφιακή αφήγηση The Montgolfier Βrothers Digital Story (προτείνεται να διδαχθεί στο Unit 4, Lesson 3, Αγγλικά Στ Δημοτικού)

Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3

Ρύθμιση σε whitelist

Οδηγός εκκαθάρισης ιστορικού cookies περιηγητή

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

Reminders: linear functions

the total number of electrons passing through the lamp.

Matrices and Determinants

«Τέχνη, εικονική πραγµατικότητα και πολυχρηστικά συστήµατα καλλιτεχνικής έκφρασης».

ΣΟΡΟΠΤΙΜΙΣΤΡΙΕΣ ΕΛΛΗΝΙΔΕΣ

Tridiagonal matrices. Gérard MEURANT. October, 2008

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible.

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ - ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ ΕΠΛ 133: ΑΝΤΙΚΕΙΜΕΝΟΣΤΡΕΦΗΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΕΡΓΑΣΤΗΡΙΟ 3 Javadoc Tutorial

Code Breaker. TEACHER s NOTES

ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ. Ψηφιακή Οικονομία. Διάλεξη 10η: Basics of Game Theory part 2 Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών

Test Data Management in Practice

Fourier Series. MATH 211, Calculus II. J. Robert Buchanan. Spring Department of Mathematics

Exercises 10. Find a fundamental matrix of the given system of equations. Also find the fundamental matrix Φ(t) satisfying Φ(0) = I. 1.

Fractional Colorings and Zykov Products of graphs

Transcript:

ΠΓΣ 518: ΧΕΔΙΑΜΟ ΗΛΕΚΣΡΟΝΙΚΩΝ ΠΑΙΧΝΙΔΙΩΝ Θέμα: Βασικά για Scripting Tutorial 3: Attack the wall 1. Create a new project 2. Import Packages: When you complete your prototyping environment will feature a floor comprised of a cube primitive, a main camera through which to view the 3D world, a Point Light. It will look something like this: - 1 -

SETUP THE SCENE 3. Create a Cube: Name: Floor Position (0, 0, 0) (YOU CAN DO THAT ALSO USING Reset Position option see image below) Scale (100, 1, 100) 4. Create a Point Light: Position (0, 20, 0) Range 40 ANOTHER BRICK IN THE WALL Let s make a wall of bricks. We ll do this by creating a single master brick and duplicate it Building the master brick 5. Create a Cube Position (0,1,0) Focus on your object: Select the Cube in the Hierarchy. Hovering your mouse in the Scene view and press F. 6. Add physics to your Cube Component Physics Ridigbody (from the top menu) 7. Color the Cube by creating a Material: Create a Material (Project view) Rename it Red Inspector Click the color block of Main Color Choose a red color - 2 -

Apply the material by dragging this material Red on the Cube Now our cube is ready to be duplicated but let s have a quick look at the physics in action 8. Select Cube Position Y = 15 Rotation X = 40 Press PLAY Set back the values: Position Y = 1 Rotation X = 0 Snap To help position your objects, Unity allows you to snap to specific increments when dragging these increments can be redefined by going to Edit Snap Objects To use snapping: hold down Command(MAC)/Control(PC) when using the translate tool (W) 9. In order to start building the wall duplicate the Cube: Command/Control + D Snap-move your cube one unit in the X axis, shown as follows: Repeat this procedure of duplication and snap-dragging until you have 10 cubes in a row/line - 3 -

Grouping and duplicating with empty objects 10. Create an empty object: GameObject Create Empty from the top menu Name: CubeHolder Position (4.5, 0.5, -1) 11. Drag the list of 10 Cubes in the CubeHolder (in the Hierarchy) in order to make the CubeHolder the parent of the 10 Cubes 12. Duplicate the parent object (CubeHolder) and use Snap-dragging as before to lift by 1 unit in the Y axis Repeat the procedure to create 8 rows of bricks - 4 -

KNOCK IT DOWN! Now that we have build the wall, let s make a simple game mechanic, where the user can maneuver the camera and shoot the bricks at the wall and knock it down 13. Setting the camera facing the wall. Select the Main Camera Position (4, 3, -15) Rotation (0, 0, 0) WALL ATTACK! 14. Create a new Javascript script Name: Shooter Script: var bullet : Rigidbody; var power : float = 1500.0; var movespeed : float = 5.0; function Update(){ Remember to save your script! 15. Attach Shooter script on the Main Camera Do this by dragging the script (Project view) on the Main Camera object (Hierarchy) Moving the camera We want to use the arrow keys in the keyboard so we need to be aware of how to address them in the code. Unity has many inputs that can be viewed and adjusted using the Input Manager. Edit Project Settings Input - 5 -

Two of the setting for Input are Horizontal and Vertical. These rely on an axis based input that when holding the Positive Button builds to a value of 1, and when he hodling the Negative Button builds to a value of -1. Example in the script: Input.GetAxis( Horizontal This receives the current value of the horizontal keys a value between -1 and 1 depending upon what the user is pressing. 16. Change the Update function of the Shooter Script to the code below function Update () { var h : float = Input.GetAxis("Horizontal") * Time.deltaTime * movespeed; var v : float = Input.GetAxis("Vertical") * Time.deltaTime * movespeed; Explanation: - 6 -

Time.deltaTime is the time it takes from one frame to the next one we use this to have a consistent amount per second regardless the framerate!! Ανεξαρτιτωσ αν είναι διαφορετικόσ ο ρυκμόσ απεικόνιςθσ του κάκε frame (λόγω πολλϊν ι λίγων υπολογιςμϊν) να γίνεται με τον ίδιο τρόπο/ρυκμό θ αλλαγι τθσ μεταβλθτισ. 17. Translate the camera: add the bold line of the code in the Shooter Script function Update () { var h : float = Input.GetAxis("Horizontal") *Time.deltaTime * movespeed; var v : float = Input.GetAxis("Vertical") * Time.deltaTime * movespeed; transform.translate (h, v, 0); With this extra line of code we say to the Unity to change the Translate variable of Component Transform (of the object that runs the current script) with values (h, v, 0) for x, y, z axis respectively. Remember we attached this script (Shooter) on the MainCamera so this will affect the MainCamera BE CAREFUL WITH CASE OF THE LETTERS IMPORTANT!!!!! Save your Script (from MonoDevelop editor) Save your Scene (from Unity) Remember both in the Assets folder Making a bullet/projectile (ςφαίρα όπλου) Creating the projectile prefab 18. Create a Sphere Select the Sphere and note at the inspector the 3 components: Mesh Filter: This is to handle the shape Renderer: This is to handle the appearance Collider: This is to manage interactions (collisions) with other objects 19. Create a Material, blue color, name the new material as bulletcolor and apply this color on the Sphere you have just created 20. Add physics - 7 -

Select the Sphere Bullet and add a Rigidbody component Component Physics Rigidbody As we wish to fire this bullet/projectile (ςφαίρα όπλου) when the player presses a key, we do not want the bullet to be in the scene from the beginning, but instead we want to be stored and created when the key is pressed. For this reason we will store the object as a prefab and use our script to instantiate (that is, create an instance of) it, only when a key is pressed. 21. Storing with prefabs: Click Create at the Project panel Choose Folder, then rename it Prefabs Drag the Bullet object (from Hieararchy) into Prefabs folder (Project panel) Rename this new prefab form Sphere to Projectile Delete the object Sphere from the Hierarchy Note that dragging a GameObject into the Project panel will save it as a prefab-there is no need to be in a folder named Prefabs however it s good to be well organized ;) Firing the projectile 22. Return to the Shooter script we have been working before function Update () { var h : float = Input.GetAxis("Horizontal")*Time.deltaTime*moveSpeed; var v : float = Input.GetAxis("Vertical")*Time.deltaTime*moveSpeed; transform.translate(h,v,0.0); if(input.getbuttonup("fire1")) { This IF statement listens for the key applied to the Input button named Fire1 to be released Left Ctrl OR left mouse button (unless you change it from Input Manager Edit Project Settings Input) - 8 -

Using Instantiate() to spawn/create objects The Instantiate command/function requires 3 pieces of information namely Instantiate(what to make, where to make it, a rotation to give it) 23. Change Shooter script as below: var bullet : Rigidbody; var power : float = 1500; var movespeed : float = 5; function Update () { var h : float = Input.GetAxis("Horizontal")*Time.deltaTime*moveSpeed; var v : float = Input.GetAxis("Vertical")*Time.deltaTime*moveSpeed; transform.translate(h,v,0.0); if(input.getbuttonup("fire1")) { var instance:rigidbody; instance = Instantiate(bullet, transform.position, transform.rotation); Create an instance of whatever object or prefab is assigned to the bullet variable Create this instance at the position and rotation from the transform component of the object that this script is attached to (in our case the MainCamera) Adding a force to the Rigidbody Having now created our object, we need it to be immediately fired forward using the AddForce() command. This command works as follows: Rigidbody.Addforce(Direction and amount of force expressed as a Vector3) - 9 -

Vector3 is a data type, a vector, with 3 components e.g. Vector3 (2,4,1); 24. Shooter script: var bullet : Rigidbody; var power : float = 1500; var movespeed : float = 5; function Update () { var h : float = Input.GetAxis("Horizontal")*Time.deltaTime*moveSpeed; var v : float = Input.GetAxis("Vertical")*Time.deltaTime*moveSpeed; transform.translate(h,v,0.0); if(input.getbuttonup("fire1")){ var instance:rigidbody; instance = Instantiate(bullet, transform.position, transform.rotation); var fwd:vector3; fwd = transform.transformdirection(vector3.forward); We have created a Vector3 type variable and name it fwd. We told it to represent the forward direction of the current transform this script is attached to (Main Camera) δθλαδι να ζχει τθν κατεφκυνςθ προσ τθν οποία κοιτάηει θ κάμερα μασ Το TransformDirection χρθςιμοποιείται για να μετατρζψει ζνα local direction ςε world direction Vector3.forward κα μποροφςαμε να γράψουμε και Vector3(0,0,1) δθλαδι θ κατεφκυνςθ προσ τθν οποία βλζπει θ κάμερα ςτο τοπικό ςφςτθμα - 10 -

ςυντεταγμζνων τθσ (πάντα οι κάμερεσ βλζπουν by default προσ τον Ζ τουσ άξονα) 25. Shooter script: var bullet : Rigidbody; var power : float = 1500; var movespeed : float = 5; function Update () { var h : float = Input.GetAxis("Horizontal")*Time.deltaTime*moveSpeed; var v : float = Input.GetAxis("Vertical")*Time.deltaTime*moveSpeed; transform.translate(h,v,0.0); if(input.getbuttonup("fire1")) { var instance:rigidbody; instance = Instantiate(bullet, transform.position, transform.rotation); var fwd:vector3; fwd = transform.transformdirection(vector3.forward); instance.addforce(fwd*power); We applied the force by first referring to the variable that represents the newly created object, i.e. the variable instance Then using the AddForce command we add a force in the direction of fwd variable multiplied by the power (the variable that we created earlier) in order to do it faster. Save your script!! - 11 -

26. Assign the Projectile prefab to the Bullet public variable of the Shooter Script of Main Camera: Drag the Projectile prefab from the Project panel onto the Bullet variable at Inspector where it currently says None (Rigidbody) PLAY THE GAME!!!! - 12 -