Ant’s Lesson: Projectiles

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:

Code screenshot 1.PNG

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 –

Instantiate

transform.rotate

input.getaxis

input.getkeydown

Rotate is called at the bottom of code here.

shoot

code-screenshot-2

Explain the use of a conditional –

A conditional can be used when you want a function to be carried out only under certain parameters.

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s