程序代写代做代考 c# go game 31263 / 32004 Game Development Lab Week 5

31263 / 32004 Game Development Lab Week 5
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 an 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
• Open the project folder in Unity. This is similar to the solution from last week so it should look familiar. Open Week5Scene if it is not already open.
• Create an empty GameObject from the GameObject menu and call it “ParentObj” and set clear its position and rotation by selecting the gear icon of the Transform component and clicking “Reset”.
• Apply the PrintAndHide component to the ParentObj instance and change the tag to “Red”.
40%
• Create a Cube primitive from the GameObject menu.
• Scale it to (1.5,0.75,1), reset the position and rotation, and apply the RedMaterial to it.
• Add the cube as a child of ParentObj by dragging it onto the ParentObj in the Hierarchy
Window.
• Associate the cube’s Renderer with the ParentObj’s PrintAndHide.rend variable in the
Inspector Window.
50% (P)
Created by: Dr. William Raffe UTS CRICOS PROVIDER CODE 00099F

• Override the prefab reference of RedPrefab in the Project Window so that the prefab has this parent-child relationship. Do this by dragging ParentObj in the Hierarchy Window to RedPrefab in the ProjectWindow and accepting any warning.
• Do the same for the BluePrefab by changing the cube’s material to BlueMaterial, the tag Blue, and replacing the BluePrefab in the Project Window.
• Delete the ParentObj and its child from the Hierarchy Window.
• Modify the LoadAssets script so that when redObj is initiated it is placed at (2,1,0) and the blueObj is at (-2,-1,0).
• Create a new C# script called InputManager and attach it to the MainCamera.
• In InputManager, make a private member variable that is an array of Transforms called
“transArray”.
• When the game starts this script should:
o Declare transAray as an array of size 2.
o Assign the Transform components of redPrefab and bluePrefab to this array (tip:
search GameObject.FindWithTag(…))
• Important: InputManager should do its starting actions in Start() and LoadAssets should
do its starting actions in Awake(). Consider why this is (see Week 4 Lecture) and take note of it!
60%
(P)
• In Update() of InputManager, detect whether the player has pressed the “W” (tip: see Input.GetKeyDown(…))
o When pressed, the redObj should be rotated by 45 degree around the z-axis and the blueObj by -45 degrees around the z-axis. (tip: Search Transform.Rotate(…))
o Doesthiswithoutcreatinganynewvariables
70% (C)
• Go to “Edit->Project Settings->Input” and edit the Fire1 axes to be bound to the “Q” key.
• In Update() of InputManager, detect whether the player has pressed the Fire key (tip:
see Input.GetButtonDown(…))
o When pressed, the redObj and blueObj should swap their vertical positions but
keep their horizontal positions. (tip: search Transform.position and see Status-
100Percent executable to see the correct behaviour)
o This flip-flopping should happen every time Fire1 is pressed and should
regardless of what their starting position are.
80%
(D)
• In InputManager, when the Fire1 key is released:
o Get the rend variable from the PrintAndHide component on the redObj. Change
the color to be a random value between (51.0,0.0,0.0) and (255.0,0.0,0.0). (tip: see Transform.GetComponent<>(), Material.color, and the class Color – note that new Color(…) takes values between 0.0f and 1.0f for standard colors).
o Repeat for blueObj but for the range (0.0,0.0,51.0) and (0.0,0.0,255.0).
o Print both of these new values to the console in the form “Red: ” by
passing the material.color variable directly to the debug statement. • In PrintAndHide, comment out all the console printing.
90% (HD)
Created by: Dr. William Raffe UTS CRICOS PROVIDER CODE 00099F

100%
(HD)
• In InputManager, when the “E” key is pressed:
o If redObj and blueObj have a PrintAndHide component, then remove it.
o If redObj and blueObj do not have a PrintAndHide component, then add it and
ensure that the gameobject it is added to is active. • In PrintAndHide, when the component is added, it should:
o Assign the rend variable if it is not already assigned.
o Ensure that the renderer referenced by rend is enabled.
• Pressing play, then “E”, then “Q” will cause a NullReferenceException error in the
console
o Prevent the error such that pressing Play, “E”, then “Q” will still swap the vertical
positions of the cubes but not change the cube colors. • CLEAN, EFFICIENT, ELEGANT CODE!
Submission
When you 1. 2. 3. 4. 5. 6.
7. 8.
complete the activity to the grade threshold that you want, you then need to:
Complete the “Status-StudentSubmission.txt” file in the highest level of the project folder. Remove all other “Status-…” files and folders to reduce the size of your project.
Remove the “Library” folder
Zip the entire project folder.
Re-name the zip file to “[student ID]-LabWeek[week number].zip”.
Submit the zip file to Canvas for the associated link for this week in the Lab before Monday 9am of the following week.
Failure to follow any of these could result in a 0% mark for that week.
If you finish the activity early, show it to your tutor before you submit it on Canvas so they can help you make some final corrections and mark it at that time.
Created by: Dr. William Raffe UTS CRICOS PROVIDER CODE 00099F