Solo game: Week 3

My goals for this week were to:

  • Add kill collision that resets the level
  • Make the collectable item the goal
  • Add shooting to the enemy

The first thing I did was add some new collision code to the character control script I made.

Collision reset code

This makes the level restart whenever the main character runs into either the walls or the enemy.

 

The next thing that I did was to add some code which makes the collectable code take you to the next level. I don’t currently have a next level, so instead it takes you to the same level, but I definitely added in different code that makes a win state.

Item next level


 

Making the enemy shoot took a long time, but I eventually worked it out. Firstly, I made the projectile code that I added to the fire.

AutoFire code

After I added the code, I added a collider and a rigidbody, and I made it a prefab so that it would be saved with these settings. I then made the auto fire code so that it would automatically shoot.

Projectile code

This next part took me a long time to work out, because I wasn’t entirely sure where which code needed to be, however I eventually worked out that the auto fire code needed to be Prefab goofattached to the enemy, and that the ‘projectile prefab‘ needed to have a prefab of the projectile in it. This was a really simple fix in hindsight, but at the time I was completely stumped.

Shooting right update

I now have an enemy that shoots only to the right. My next step is to add code that makes the enemy shoot in the direction that it is moving, and to add code that toggles the shooting off and on whenever the enemy sees the main character, however this will be in a seperate post because this too was a long and arduous process.

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