This week in Ant’s lesson we had a unity file shared with us containing three ships with code attached that Ant had created, one ship constantly fired every few seconds, the other two would fire when space bar was pressed, however, one would be from the front of the ship and one would be from every direction, the amount of bullets shot could be changed.
We were told to review the “Firing1” code which was attached to the ship that fires directly in front so I’m going to do it in a Blog:
List all of the variables created –
“projectilePrefab” which should link to the prefab you want to spawn when the object shoots.
“rotationSpeed” controls the rotation speed of the object.
“Degrees” Calculates how much to rotate.
Explain the datatype of each –
A GameObject is used to represent any object with Unity and a Float which can store any number, including decimals .
List the functions declared –
“shoot”, “Update” and “rotate”.
List the functions called –
Rotate is called at the bottom of code here.
Explain the use of a conditional –
A conditional can be used when you want a function to be carried out only under certain parameters.