Unit 8:Devlog 4- Units

Initially I was scouring for videos because I didnt want to think for myself so I found all of these to procrastinate:
https://www.youtube.com/watch?v=DhtXMhhcqlw&list=PLWEZzX6-1qwXy1J0ezamKzXei7MztMDJ6&index=8

https://www.youtube.com/watch?v=PtyGJi__HcY&list=PLWEZzX6-1qwXy1J0ezamKzXei7MztMDJ6&index=13

https://www.youtube.com/watch?v=l2hzXQUmDwE&list=PLWEZzX6-1qwXy1J0ezamKzXei7MztMDJ6&index=14

https://www.youtube.com/watch?v=TCa8khfy5Nk

Though I did not use any of them or watch them fully since they were quite long.

I firstly I created some general float variables for the unit stats:

I then created a Collision sphere for the Range of the unit and created a simple piece of code to set the float range to the actual collision radius correctly.

I then experimented with targeting and decided on creating an array to list all enemies in range so In the future I can choose between them for targeting and this may help with chain/ splash damage effects I may create. They also remove themsleves when they leave the range or are killed so that there won’t be any invalid targeting.

One of the events ran by the array code above is:

While this isnt fully integrated with the future UI button that will switch the target between “last/ first/ strongest/ Weakest”,
It runs a function in the enemy to send its current stats:

Which I then gather and can use and send the updated health after applying the damage back to the enemy

I quickly realised this was very inefficient though and replaced it with these 2 functions:

(in the Unit)

(in the enemy)

I then tested with creating the pop up on hover but didnt get It functioning properly before I got distracted with re-writing the attack code, so I will write about it next week.

I then re-wrote the majority of my attack code twice and came out with this:

Click to Open in fullscreen

Which functions esactly how I want it accounting for attack speed like I planned on my unit 8 page.

In future blogs I will probably create one called “upgrades” or something alike, in which I will work on the pop up upgrade UI I mentioned starting before and also create the actual upgrade system, ticking off another key feature I need to create.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *