31263 / 32004 Game Development

31263 / 32004 Game Development

Lab Week 4

Getting Started

1. Download the corresponding week’s zip file from this week’s module on Canvas.

2. Unzip the project folder and open it in Unity. If there are any warnings about difference in versions, just continue. If this causes any red errors in the console once the project opens, notify the tutor.

3. Within the weekly folders there are image and executable files starting with “Status…”. These files give you a preview of what is expected for each point percentage below.

a. If you are on Mac and the Status-100Percent App file won’t run, hold control and click (right click) then select Open, if there is a security warning, acknowledge it and press open again.

i. If you still have trouble, you may need to change the permissions of the file with the following command in a Terminal window: chmod -R +x Status-100Percent-Mac.app/Contents/MacOS

b. If you are running the Windows executable on the lab computers, you need to copy the entire executable folder into Windows(C:)/Users//AppLockerExceptions. From there you can double run the .exe file.

Tasks

Points                                         Requirements

40%

Setting your Default Script. Editor

• Create a new C# script. called Test.

o In the Start method, start typing “Deb”

o You should have an auto-complete that says “Debug”. Select this, then start typing “.Lo” and select the Debug.Log() method.

 If this is not the case, follow the instructions in the Week 5 Module on Canvas to synch the Visual Studio IntelliSense Autocomplete with Unity.

o Finish this to be Debug.Log(“Test”);

• Attach this script. as a component of the MainCamera by dragging it onto the Camera.

50% (P)

Initializing a repository

• See this week’s lecture for hints on how to complete the following through Git Bash or explore it through the use of Sourcetree or GitHub (installed in the lab room).

o For ease of instruction and consistency, the below instruction are for Git Bash (or using Git in the Terminal if you are on Mac)

• Create a new repository on GitHub.com (or your git host of choice, such as BitBucket, GitLab, etc.)

• Initialize a local repository in the Unity Activity folder for this week (hint: see “git init”)

o This should be at the same folder level as the folders “Assets”, “Project Settings”, etc.

o This will create a hidden folder named “.git”. See next instruction on how to reveal hidden directories in your operating system.

• In the same directory as your “.git” folder, create a file called “.gitignore”

o The .git folder may be hidden in your file browser, and because .gitignore has a “.” at the start, it may also be hidden on Macs.

 In Windows, use the following instructions to show hidden files: https://support.microsoft.com/en-au/help/4028316/windows-view-hidden-files-and-folders-in-windows-10

 In Mac, in the terminal use “ls -a” (that is a lower case “L”) to show list hidden files.

o In the .gitignore file, paste the code from the following: https://github.com/github/gitignore/blob/master/Unity.gitignore

o This will ensure that certain unnecessary files will not be committed to your online repository, freeing up space and speeding up your commit process

• Add your GitHub repository as a remote of the local repository (hint: see “git remote”)

• Add all the files in the activity folder to the repository (hint: see “git add”)

• Commit all changes to the local repository (hint: see “git commit”)

• Push all the changes to the remote GitHub repository (hint: see “git push”)

o If you are using GitBash (the terminal) with a GitHub.com repository, you may get an error when you try to put in your login details. If so, you should follow the instructions in the following link to create a personal login token OR use GitHub Desktop instead (it will handle authentication for you) - https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token

Set the ProgressEvaluator to band that you just completed (see left grey column) and press Play to test your progress for known errors.

60% (P)

Set the ProgressEvaluator’s “Band Reached” variable to “Deactivate” and continue with the lab.

Setting up prefabs and referencing them in scripts

• Create a new branch of your repository called “dev” by using “git checkout -b dev”.

• In Unity, open this week’s scene to begin developing.

• create a red material and a blue material and set their albedo accordingly

o Create two spheres in the scene, one with the red material, the other with the blue material.

o Now create two prefabs from these called RedPrefab and BluePrefab

o Delete the two sphere gameobjects from the scene.

• Right click in the Project Window and create a new C# script. called “LoadAssets”

• Open up the LoadAssets script.

• Create a public GameObject member variable called redObj of the LoadAssets class (i.e. outside of any method).

• Save the script. and return to the Unity window to auto-compile it.

• In the Hierarchy panel, create a new empty GameObject, rename it to “LoadManager”, set all position and rotation values to 0, set all scale values to 1, and add the LoadAssets script. as a component of this game object

• Assign the RedPrefab prefab to the redObj variable of the LoadAssets component of the LoadManager game object.

• Save your Unity scene (ctrl+s or cmd+s), then in your repository

o Add all the changes to your local repository (git add -A)

o Commit the changes to this branch (git commit -m “60 percent complete”)

o Push the changes (git push origin dev)

Set the ProgressEvaluator to band that you just completed (see left grey column) and press Play to test your progress for known errors.

• Open the ProgressEvaluator.cs file and uncomment (i.e. remove the // symbol) the line at the top that says #define Pass60

70% (C)

Set the ProgressEvaluator’s “Band Reached” variable to “Deactivate” and continue with the lab.

Instantiating Prefabs as GameObjects through code

• Create a private GameObject member variable called blueObj of the LoadAssets class but make it available to the Inspector View (tip: search SerializeField in Unity Docs).

• Open the LoadAssets script. again. When the game starts, the LoadAssets component should create a redObj at (2,0,0) and a rotation of zero and a blueObj at (-2,0,0) and a rotation of zero (tip: search Instantiate, Vector3, and Quaternion.identity in Unity Docs).

• Save the script, assign BluePrefab to blueObj on the LoadManager game object, and press play in Unity to see the results.

Setting a consistent frame-rate

• When the LoadAssets component is first run, use the method in the following documentation to limit the framerate to 60 frames per second.

o https://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html

o If you have a reasonable powerful computer, this will slow down the game to help with seeing the output of the rest of the code in this activity.

• With your repository – add, commit, push

Set the ProgressEvaluator to band that you just completed (see left grey column) and press Play to test your progress for known errors.

80% (D)

Set the ProgressEvaluator’s “Band Reached” variable to “Deactivate” and continue with the lab.

Printing GameObject properties

• Create and checkout a new branch in your local repository called “feature-print”

• In Unity, create a new script. called “ConsolePrint”

• Edit the RedPrefab and BluePrefab prefabs to have a ConsolePrint component.

• For every frame, the ConsolePrint script. should print the following “GameObject’s name:i”

o “GameObject’s name” is the name of the game object that the component is attached to.

o “i” is an integer that is set to 3 at the start of the game and increments by 1 at the start of every frame. (i.e. the first Debug.Log statement should say 4 on it).

o There should be no white-spaces in this string

• Press play in Unity and observe what happens.

• In your repository – add, commit, push

Set the ProgressEvaluator to band that you just completed (see left grey column) and press Play to test your progress for known errors.

90% (HD)

Set the ProgressEvaluator’s “Band Reached” variable to “Deactivate” and continue with the lab.

Renaming files, referencing components, and using tags

• Change the name of ConsolePrint in the Project Window to “PrintAndHide” and fix any errors that arise.

• In PrintAndHide make the member variable “public Renderer rend”.

o Select RedPrefab in the Project Window, then drag it onto its own PrintAndHide.Rend reference.

o Repeat the above for BluePrefab.

• Create a new Tag called “Red” and change the RedPrefab tag to this.

• Create a new Tag called “Blue” and change the BluePrefab’s tag to this.

• In your repository

o Add, commit, push the “feature-print” branch

o Checkout the “dev”

o Merge “feature-print” into “dev” (hint: see “git merge”)

o Push the “dev” branch

Set the ProgressEvaluator to band that you just completed (see left grey column) and press Play to test your progress for known errors.

• Open the ProgressEvaluator.cs file and uncomment (i.e. remove the // symbol) the line at the top that says #define HD90

• The Console Window is going to get spammed (and this is needed for the ProgressEvaluator)

o Make sure you are looking at the top right of the Console window to see if there are any red exclamation marks (errors).

o Click the white exclamation mark (normal log output) to hide the output coming from your PrintAndHide script. if needed to see the ProgressEvaluator yellow and red messages easier.

100% (HD)

Set the ProgressEvaluator’s “Band Reached” variable to “Deactivate” and continue with the lab.

Deactivating GameObjects and Disabling Components

• Create and checkout a new repository branch called “feature-hide”

• In the PrintAndHide script.

o If the Tag of the game object is “Red” and i = 100, deactivate the game object.

o If the Tag of the game object is “Blue” and i = a random integer between 150 and 250 (inclusive of the numbers 150 and 250) which is generated when the game starts, disable the Renderer component of this object.

• Press play in Unity and observe what happens, especially in the console.

• In your repository

o Add, commit, push the “feature-hide” branch

o Checkout the “dev” branch a merge “feature-hide” into it

o Push the dev branch

o Merge the “dev” branch into the “master” branch and push the master branch

• View your git commit tree (in git bash, you can use gitk or see the GitHub online project page under “Commits” to see the tree)

o Compare it with the one on the next page

o You will not be marked down in this activity if does not look like this, but if it doesn’t, try to analyze where and why it went wrong.

CLEAN, EFFICIENT, ELEGANT CODE!

Set the ProgressEvaluator to band that you just completed (see left grey column) and press Play to test your progress for known errors.

• Make sure to wait until you see the message “PROGRESS EVALUATOR: HD100 Band: No common mistakes found”.

• This should occur sometime before frame. 300.

Bonus

Submit your work on Canvas before continuing. Follow the instructions on the last page.

This part is optional. If you completed the above activity very quickly, try this. It is not graded, but it will enhance your skill.

Assemblies

• While your code is likely compiling quite fast at the moment, this will become much slower as you add more scripts.

o Every time you change one script, Unity re-compiles everything! Imagine how bad this gets when you have ten’s of thousands lines of code spread across dozens of script. files.

o If you’ve been using Unity for a few years, you’ll also notice that a new dialog box pops up during compilation saying “Reloading script. assemblies”

• So what are “Assemblies” and how can they speed up your compile speed?

o In short, they are C# code packages (also know as Dynamic Linked Libraries or DLL’s). They allow logically linked code to be packaged/assembled together and left untouched during compilation unless any of the code in that assembly has changed.

o Look into assemblies more at

https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html and find tutorials such as https://youtu.be/eovjb5xn8y0

o Add a few extra dummy C# scripts to your project (you can pull some from past week’s lab activities)

o Then begin to organize them into assemblies

o Depending on your computer hardware and the number of lines of code you have in your project, you may or may not notice a speed difference.

o Regardless, keep this technique in mind when you are working on your Assessment 3 and 4 or on projects in 31262/32003 Introduction to Computer Game Design, 31102 Game Design Studio 1, or the Playmakers Dev Team extracurricular project.

Git Repo Tree

Each circle is a commit. Circles with a percent show when they should have been committed. Circles with a “M” are when a merge occurred and an auto-commit was made. If your Git Tree looks more flat (like a single line) that is fine, just make sure that the tag for each branch stops at its highest commit or merge point.

Submission

When you complete the activity to the grade threshold that you want, you then need to:

1. Evaluate your progress:

a. Make sure that you have run the “ProgressEvaluator” at the final band you achieved.

b. Not doing so is an indication that you are not evaluating and tracking your own learning.

2. Complete the plagiarism declaration:

a. Complete the “COMPLETE-BEFORE-SUBMISSION.txt” file in the highest level of the project folder.

3. Reduce file size:

a. Remove all files and folders starting with the “Status-…” prefix

b. Remove the “Library” folder

4. Preparing your zip file:

a. Zip the entire project folder.

b. Re-name the zip file to “[student ID]-LabWeek[week number].zip”.

5. Submit the zip file to Canvas for the associated link for this week in the Lab before Monday 9am of the following week.

6. Failure to follow any of these could result in a 0% mark for that week.

基于遗传算法的新的异构分布式系统任务调度算法研究(Matlab代码实现)内容概要:本文档围绕基于遗传算法的异构分布式系统任务调度算法展开研究,重点介绍了一种结合遗传算法的新颖优化方法,并通过Matlab代码实现验证其在复杂调度问题中的有效性。文中还涵盖了多种智能优化算法在生产调度、经济调度、车间调度、无人机路径规划、微电网优化等领域的应用案例,展示了从理论建模到仿真实现的完整流程。此外,文档系统梳理了智能优化、机器学习、路径规划、电力系统管理等多个科研方向的技术体系与实际应用场景,强调“借力”工具与创新思维在科研中的重要性。; 适合人群:具备一定Matlab编程基础,从事智能优化、自动化、电力系统、控制工程等相关领域研究的研究生及科研人员,尤其适合正在开展调度优化、路径规划或算法改进类课题的研究者; 使用场景及目标:①学习遗传算法及其他智能优化算法(如粒子群、蜣螂优化、NSGA等)在任务调度中的设计与实现;②掌握Matlab/Simulink在科研仿真中的综合应用;③获取多领域(如微电网、无人机、车间调度)的算法复现与创新思路; 阅读建议:建议按目录顺序系统浏览,重点关注算法原理与代码实现的对应关系,结合提供的网盘资源下载完整代码进行调试与复现,同时注重从已有案例中提炼可迁移的科研方法与创新路径。
【微电网】【创新点】基于非支配排序的蜣螂优化算法NSDBO求解微电网多目标优化调度研究(Matlab代码实现)内容概要:本文提出了一种基于非支配排序的蜣螂优化算法(NSDBO),用于求解微电网多目标优化调度问题。该方法结合非支配排序机制,提升了传统蜣螂优化算法在处理多目标问题时的收敛性和分布性,有效解决了微电网调度中经济成本、碳排放、能源利用率等多个相互冲突目标的优化难题。研究构建了包含风、光、储能等多种分布式能源的微电网模型,并通过Matlab代码实现算法仿真,验证了NSDBO在寻找帕累托最优解集方面的优越性能,相较于其他多目标优化算法表现出更强的搜索能力和稳定性。; 适合人群:具备一定电力系统或优化算法基础,从事新能源、微电网、智能优化等相关领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①应用于微电网能量管理系统的多目标优化调度设计;②作为新型智能优化算法的研究与改进基础,用于解决复杂的多目标工程优化问题;③帮助理解非支配排序机制在进化算法中的集成方法及其在实际系统中的仿真实现。; 阅读建议:建议读者结合Matlab代码深入理解算法实现细节,重点关注非支配排序、拥挤度计算和蜣螂行为模拟的结合方式,并可通过替换目标函数或系统参数进行扩展实验,以掌握算法的适应性与调参技巧。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值