Damaging Enemies

Taking a slightly different route, I decided to add the ability to damage on the projectile rather than on the enemy/player. This way, if I create many different weapon projectiles with different damage values, I can adjust them and send those values over to the enemy object.

The key to this is to create a Damage() function on your object that needs to take damage. Every time this function is called, a chunk of health is taken away.

From the capsule perspective, it will check if whatever it collides with in the trigger has the enemy behavior and do a null check. If it does collide with the enemy and it has the enemy behavior, it will then tell the enemy to run the damage function.

--

--

--

Unity Developer and Software Engineer who loves making games with GameDevHQ

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Android developer summit 2021

Basic Android MVVM with Kotlin Coroutines and Retrofits

Top 25 Resources 🎁 to Learn Flutter in 2021

Communicating Between Apps Using BroadCastReceivers

broadcasting

Android — How to make an Android device vibrate? with different frequency?

The Art of download size optimization for Android applications in practice

Kotlin ListView with custom BaseAdapter and API integration

How to Upload App on Google Play Store.

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
Al Heck

Al Heck

Unity Developer and Software Engineer who loves making games with GameDevHQ

More from Medium

Making a generative recreation of Wassily Kandinsky’s Composition II, 1923, in p5.js

📜WANTED: BLOCKMINE DEVELOPERS⛏

Japan’s Financial Service Agencies “whitelisted” 20 virtual currencies in fall 2017 and it changed…

Maynard Ferguson, Sponge Bob, Rabbits, and a Scary Handshake