Fox Game Update

gameshot

Since adding the enemy and goal to my game, I’ve added some new features. I added in walls to my scene with a box collider and rigidbody2D attached to them. I discovered that if I set the black walls further back (-10 in Z axis), they fell behind the camera so were invisible to the camera in game, but still acted as walls to the player. as the walls became invisible in-game, I added some decorative white doorways to show where you could enter and leave each room.

To the Cat enemy I added 2 new scripts, Autofire, and Waypoint 1 (these are scripts to make the Cat shoot a claw bullet, which I added to prefab after making it in Photoshop, on an automatic timer, and make it run backwards and forwards in the living room whilst shooting.

cats scripts

I set up a second level (where I moved the Cat, giving it new Waypoints, and the Swag Bag positions) and then added the scene to my project. I made a build with level 1 and 2, then went on to code the next level to be triggered when you collide with the swag bag.

I used a script to achieve this I called ‘newlevel’, which I attached to the Fox player :
newlevel

Because the ‘nextLevel’ string is public, I can write the name of the next level in the box below the script which appears on the inspector; in this case I typed “Level2”. It worked after some difficulty putting things in the right place, including the tags I applied.

Tags separate assets into groups. In this case the tag for the bag was ‘goal’ (as seen on line 10 of the script on the picture). Ant’s tutorials covered these, and they were important, because the walls and bullets have colliders too so the level would be won every time the fox collided with anything, not just the bag, if i didn’t specify the type of object which would trigger a next level when collided with. This simple line changes the game completely!

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