RSS

GAM 111.3 Reflective Development Logbook Blog 11 (Week 12)

08 Dec

Week 12, and the final blog post for this trimester.

In this particular class, we didn’t work on any projects or get taught anything. Instead if we had any problems or questions about the game we have been making, our lecturer was more than happy to offer some advice.

One particular problem, one I hadn’t even thought of up until this point (and also that the lecturer helped me point out).

Although the towers were using ray casting to find their targets, and then if the raycast hit a game object with the tag “Enemy” it would instantiate a projectile. But the problem was that the way I wrote the code. The code that is written to make a projectile wasn’t in the ray casting function. So “if” the raycast hit an enemy { make a projectile }, instead it was if the raycast hits an enemy { } make a projectile. So no matter if the raycast hit a target or not, a projectile was being instantiated. So I then put making a projectile inside of the ray casting function.

No projectiles were being instantiated. Why? (Bear with my while I explain).

Multiple different ways were discussed to fix this, but every option wouldn’t work. One of the things that changed in this weeks progress is that the towers no longer contain a box collider or a NavMesh obstacle with carving. Each grid in the grid system did, and when a tower had been placed, it is made a child of the grid its placed onto. When the tower has completed constructing, the grid that the tower is now a child of gets its NavMesh obstacle and carving enabled. That way the enemies always have a clear path to run through rather than towers that rotate and constantly change the available space for enemies to run through causing inconsistencies.

As I mentioned last week, each grid is just a box collider that is a trigger.Inspector raycast

So guess what this means?

Trigger Box Collider

Towers are trying to raycast from INSIDE of the grid (trigger box collider). The raycast never makes it outside of the box. That’s why nothing was instantiating.

So turning off Raycasts Hit Triggers would completely break the grid system, the towers and also the builder.

Luckily the lecturer pointed out that he recalled a way for raycasts to ignore certain layers.

Layer Screenshot

So that’s exactly what I started to look into. And luckily enough it was surprisingly an easy enough fix.

I came across this little gem. (You don’t have to watch this).

http://docs.unity3d.com/ScriptReference/Physics.Raycast.html.

Raycasting already have a built in overload that makes them ignore layers!

What my ray cast was:

RaycastHit hit;
if (Physics.Raycast (myTransform.position, -(myTransform.position – closestEnemy.transform.position).normalized, out hit, range)) {DoSomeStuff};

All that I needed to add was  after “).normalized, out hit, range” was “, ((1<<9) | (1<<13)))).

The (1<<9) | (1<<13) says to the raycast only focus on THESE layers. Layers 9 and 13 and ignore the rest.Layers Screenshot

I want the ray cast to hit enemies, and I want the raycast to hit the ground so that ray casts don’t travel through the ground.

TADAAA – PEWPEW!

Raycasting Working


One other issue that I have is (and is still broken) that if the a second tower is placed while one tower is under construction, the unfinished tower stays unfinished. I’ve added a second building button.

Unfinished TowerEvery tower that is placed and ready to be built gets added to a list. When it is finished being built it gets removed.

So the button makes the builder target an unfinished tower in the list and is supposed to set his NavMesh destination to that tower, and if the builder is close enough to it, hes supposed to continue constructing it.

 


 

I’ve also added a way for enemies to destroy towers if their NavMesh path is blocked by checking their NavMesh.pathstatus.

If their path status is partial, they find the closest tower to them and destroy it. If their path status is complete, they continue to run the gauntlet.

The tower’s don’t have an amount of health and the enemies don’t have an attack damage. Including that would have taken more time and required setting up proper collisions to apply damage whilst following the enemies animation (similar how I did in the side scroller project we did in week 8), creating and balancing health variables etc etc. So when an enemy is close enough to a tower, it simply deactivates the NavMesh Obstacle and carving in its parent, then destroys the tower.


 

Made a main menu scene complete a play button, instructions button with a 4 page instructions, and an exit button.

Completely overhauled the look of the tower defense scene’s UI.

Added a gold nudging menu, so if gold gets stuck under a tower, it can be nudged out for the gold collector to get.

A sell tower button to refund 100% of the towers cost.

Completely overhauled the entire assignment with sounds.


Main MenuInstructions Page 1Game Scene ScreenshotBuilder UITower UIResource Tracker With TimerGold Nudging MenuSell Tower ButtonScene View 1Scene GameplayScene View 2Game Over Menu


Well, that’s my Infinity’s Edge Tower Defense.

Unfortunately that’s the last blog post for this trimester, I hope that the you’ve enjoyed this journey with me so far as much as I’ve enjoyed venturing on it.

This weeks song’s:

And to my lecturer:

Sublime trimester on your behalf.

True Story.jpg

 

That’s all for now. Enjoy the Christmas time.

 

Until next time –

FeenikxFire

Nic

 

BIG BIRD OUT!

Metal Fiery Horns

 

 

 


 

Information source:

Technologies, U. Unity – Scripting API:. Docs.unity3d.com. Retrieved 8 December 2015, from http://docs.unity3d.com/ScriptReference/Physics.Raycast.html

Msdn.microsoft.com,. List(T) Class (System.Collections.Generic). Retrieved 8 December 2015, from https://msdn.microsoft.com/en-us/library/6sh2ey19.aspx

Technologies, U. Unity – Scripting API:. Docs.unity3d.com. Retrieved 8 December 2015, from http://docs.unity3d.com/ScriptReference/NavMeshPathStatus.html

 

Image source:

All screenshots of this project are my own work – Lyness, N. (2015). Infinity’s Edge Tower Defense Screenshots. Retrieved from https://feenikxfire.wordpress.com/

Genius,. (2015). True Story. Retrieved from http://genius.com/1634764

DragonArt,. (2015). Fiery Metal Horns. Retrieved from http://www.dragoart.com/tuts/11142/1/1/how-to-draw-devil-horns,-devil-horns.htm

 

Video source:

Thy Art Is Murder Band,. (2015). THY ART IS MURDER – Holy War (OFFICIAL VIDEO). Retrieved from https://www.youtube.com/watch?v=hf04EYSifjE

Foo Fighters,. (2014). Foo Fighters – I Am A River. Retrieved from https://www.youtube.com/watch?v=9cqHAgnub_M

Advertisements
 
Leave a comment

Posted by on December 8, 2015 in Uncategorized

 

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

 
%d bloggers like this: