Download presentation
Presentation is loading. Please wait.
Published byKenneth Thompson Modified over 9 years ago
1
SE 320 – Introduction to Game Development Lecture 4: Programming in Unity & Project Presentations Lecturer: Gazihan Alankuş Please look at the last two slides for assignments (marked with TODO) 2/10/20121
2
Outline No quiz! How to write your code in Unity Project presentations 2/10/20122
3
Developing Games in Unity Activate trigger component was very useful. Sometimes it was not enough. – “I have five objects that I want activated.” – “I want this object to change color.” – “I want to count the number of times I press this button.” – “I want this button to act differently if I had clicked the other button first.” 2/10/20123
4
Can’t I just write some code? Of course you can! But how and where? – You create a new component. That’s all! Your new custom component can be used just like any other component. You can attach it to game objects however you like. You can create as many different components as you like. 2/10/20124
5
What does this imply? Your component will be attached to a specific game object. There can be multiple game objects carrying your component. – New game objects with your component can be created during runtime! You may have multiple kinds of components in a game object hierarchy. Your components may need to talk to each other. – Example 1: The player moves a lever. Your component that is attached to the lever talks to your other component that is attached to the door. That component starts moving the door. – Example 2: Player 1 gives a gold to Player 2. The inventory component attached to Player 1 talks to the other instance of the inventory component attached to Player 2. The first one does gold=gold-1 and the second one does gold=gold+1. 2/10/20125
6
Let’s start simple… The game loop – Video games are like movies, they have to quickly display a new picture so that things appear like they are moving. – For every picture, your game has to decide what will be on the picture. – You “update” the game state very often For example, 30 times a second (30fps) Why do I care? – You can write a function that Unity will call before drawing each frame. 2/10/20126
7
Example Print current time at every frame – Add a C# script component – Fill in the Update function to print current time – Add the component to a game object – Run it and see it print time very quickly This means that your function is being called many many times very fast. 2/10/20127
8
Project Presentations 2/10/20128
9
TODO: Projects Find a name for your group Have your first meeting Read the policy document here: ! Send a private report after your meeting, according to the policy document above. These will contribute to your project grade! 2/10/20129
10
TODO: Homework 4 Read and apply in Unity: – http://unity3d.com/support/documentation/Manual/Scrip ting.html (Use C# instead of JavaScript) http://unity3d.com/support/documentation/Manual/Scrip ting.html – http://catlikecoding.com/unity/tutorials/clock/ http://catlikecoding.com/unity/tutorials/clock/ Change the clock you created in the second link so that it is customized for you. Use your imagination. Get Özkan to grade your clock – ozkansayin.ieu@gmail.com (NOTE THE ADDRES CHANGE!) ozkansayin.ieu@gmail.com – Subject (paste this): SE 320 Homework 4 – What to send: Assets -> Export package File -> Build Settings -> Web player -> Build 2/10/201210
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.