Nerd For Tech
Published in

Nerd For Tech

New enemy movements and ammo text tweak

New ZigZag Movement

To start our refurbishing of our enemies, we are going to start giving them a zig zag movement pattern. First, we will need to create a couple new variables to work with.

From here, we can assign our _moveType to a random number for the switch statement we will create for unity to pick from.

Just for viewing purposes, we will check with debug.log to make sure that we are getting the proper movement patterns when the number is called. From here, we are going to move our basic move pattern into a new void and create a new zig-zag void for our new movement pattern:

With our zigzag pattern, we are letting Unity know that if our enemy unit reaches 6.5 on either side, we want it to go the opposite direction. Next, we just add these 2 new voids as part of our EnemyMovement method:

With all of this now set up, we can go into our editor and check to see if our newly created enemy movements come into play:

Now that we have a new movement pattern, we can look into creating a couple new enemy types to work with.

Ammo Count Tweak

Now for just a small little tweak to our ammo counter so that player has a visual of how much their max ammo is

What we have done is added a second int to our method so that we can call on the max ammo available to our player at the time. We will use this method rather than just going with /15 as if there are any updates to the games ammo count, it will be changed with those changes, rather than having to go back through the scripts to make sure it is proper.
Next, we will go into our player script and add/adjust a few parts of our script to include the new values:

This line of code we will include in our void start so that it displays the amount to start the game, as well as with in our fire laser method and the powerup pickup method. As these are all the different methods that alter the ammo values, we will place them in all of them so it updates properly.
Now that we have updated our script to include a total amount, let’s go into our editor and check out if it works as intended:

--

--

--

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.

Recommended from Medium

Spring Boot — MongoDB Unit testing with Embedded MongoDB

CNCF Certified Kubernetes Administrator exam tips & tricks ⛵️

How to use Related Name attribute in Django Model?

Camera Look System in Unity and Cursor Locking

Load Balancing with Service Discovery

Product Migration : Shopify To WooCommerce

Product Migration : Shopify To WooCommerce

Converting a REST endpoint to GraphQL

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jordan Evans

Jordan Evans

More from Medium

Journal 149 — Unity Project Development, 2.5D Shooter

Using the Unity Profiler

Code Optimization- Game Dev Series 145

Building A Stealth Game — Helping Your Guards “See”