Exam Prep – Individual Game (Pt.3)

This week we finished off the individual games, finally making them something of a clone of the group games with the exception that we’d understood and done all the work as individuals. I hope now this prepares me for the exam, I have zero worries about the rest of the course but a code exam? Artist’s nightmare! I over-react, the whole thing is open book and with enough preparation I’m sure I can knock out another game similar to this within the allocated period.

Office Lens 20170324-193552
The now customary post-it note for the class tasks.

Okay first task on the list, the guard needs to shoot. Took the code from Ant’s notes and the previous Trio game, bam done! The highlighted code was the edit made later on in the lesson to get the guard to shoot at the player once they’re in its cone of vision.


At this moment the code had no idea what on earth projectilePrefab was, so retroactively I imported the same laser graphic used previously (from the wonderful kenney.nl), tagged it with “Laser”, added the Projectiles script (as seen below),prefabbed the whole thing and plugged this into the public GameObject seen above in the inspector.

The projectile script, getting some good mileage being used for the third time now.
Collision detection added to the player for the tag “Laser”

So now our baddie shoots constantly and we can be hit by bullets. This is pretty much the point where I stop wrapping my head around it all, now to introduce sight to the guards. I mentioned in a post during the trio game that I wasn’t sure if line of sight was going to be required in the exam, turns out it is. So somehow I’m going to have to wrap my head around this or risk failing, which absolutely isn’t an option.

Easier said than done. During the trio game Ant more or less coded this in on our request and this time around the code was provided to us, we just had to understand enough to be able to implement it onto the correct game assets. So while that I achieved, I honestly can’t talk you through it, nor do I want to delay this post until I have a better understanding. I’ll have to return and wrap that loose end up in future before the exam.

At least I can explain some of the setup new setup, improved on since the trio game.


Above are the variables declared in the ConeandLineofSight script, the two I want to focus on are the public MonoBehaviours, normal and chasing component. These create placeholders in the inspector in which to plug in other scripts, this will be used to change the guards behaviour when he sees the player and doesn’t. He’ll either patrol as normal with the waypoints script or stop and shoot at the player using the autofire script.


The use of these variables can be seen above further down the script, activating and deactivating these as needed.

For reference here is the cone and line of sight parts of the script.




One thought on “Exam Prep – Individual Game (Pt.3)

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s