Introduction

Today on Land Crisis Dev Log!

Do you know those situtations? You know for sure that a certain thing works, but, if you are tasked to implement it, you start to realize that whatever it is you just promised, turned out to be a pile of šŸ’©?
This surely was one of those weeks. Read on to find out how FUN things can be if you (donā€™t) know what you are doing!

Development progress

current week

We are drawing closer and closer to the final alpha build. This mean that Gabriel and NightFalcon have been doing double and tripple shifts to get the animations top-notch and ready for the release. This also leaves me with the task to implement those animations. The animations I did for the prototype were simple Unity Animator Animation Clips - basically you tell it ā€œhey, at time 0 you load image 1ā€ and then, ā€œhey, at time 30, you load image 2!ā€. That works very well if you got a single unit with a single color in a single instance.
Guess what, we do not have those situations.
First of all - I needed to get the animations dynamically and implement the animation tree for that.
Fair enough, hereā€™s a partial tree.

The tree of suffering, and that's not even all of it.

Allā€™s fine here. I assign a sprite, let it run, fine.
But now for the catch: How the hell do I swap the sprite out to change it to the properly colored one?
Spoiler: You donā€™t.
Turns out, I can access the Animator from a script, I can access Animation Tree, I can access the Animation Clips but I cannot access the modifying object. I tried like a dayā€™s worth of stuff to get it to work, but it simply wonā€™t work.
Giving up on that idea, there is a 2nd thing in Unity, called ā€œEventsā€ or Animation Events.
So - solution #2 - instead of changing the sprite to the proper unitā€™s sprite and color, we use Events and trigger that from code.

Show me your secrets, button!

Little problem with that. Unity has a particularā€¦ bug feature to revert any changes made to an object after the Event is evoked.
A quick googling around finally led me to the following stack-overflow page:
https://stackoverflow.com/questions/52628791/how-to-change-image-after-animation-complete-in-unity-3d
Itā€™s not entirely my issue, but the suggested work-around fixes the underlaying issue - to rephrase: I have to re-update the sprite on LateUpdate() after the animation event is called.
Sounds like a performance nightmare, no?

Profiler, 1 sprite

One sprite - looks fine, letā€™s try 400.

Profiler, 400 sprites

Huh. 0.54 ms, on Battery on a Intel Integrated Graphics Card. Not bad.
(As a note: the big ā€œorangeā€ block is the UnityEditor that is basically the IDE/development environment. That part is not included in the final game, so this is basically ā€˜overheadā€™ that can be ignored.)

Seems like my fear was a little bit out of place here. But, just to be on the safe side - if this thing really turns out to break my neck, Iā€™ll simply revert to manuall animations.

So we sum up the progress as:

  • Added the auto-coloring coding to buildings
  • Added the auto-coloring code to units
  • Added unit animation script(s) (in progress)

Woops

By next week I should be able to show you some harvesting, attacking and building. And most likely a webm/gif - stay tuned!

Upcoming planned next steps

Another small update here:

Status Date Topic Sub-Topic Description
Work 4/28/2020 LandCrisis Development Check abilities with new GameEntity system (attack, gather)
Work 4/28/2020 LandCrisis Development Added units, animations and other graphical upgrades
Plan Ā  LandCrisis Development Import FoW implementation
Plan Ā  LandCrisis Development Static playtest, initial build

Closing statement

Again, thank you for reading. If you got any questions, hit us up on Discord, the link is here.

Stay safe, stay strong, keep your distance and Iā€™ll keep you guys updated soon!

- KuhnChris