I recently overhauled the weapon animation system in my game, and I also ended up making a 3D HUD which I think is rather nifty. (self-glaze incoming)
I wanted it to fade when it wasn’t needed because I’ve got this map I had commissioned and I really want the environment to shine. It appears when you get damaged, equip, shoot, or reload your gun, and when you don’t have a gun out, only the health bar will appear. it fades when you don’t shoot your gun or get damaged for a while, and since I had some extra space, I made a heart for it.
The heart is more dynamic than you’d think, it shifts color based on how fast it’s beating, it has a heart rate value (the same value the tween time uses), and a heart rate modifier. The heart rate modifier gets subtracted from for every second you’re sprinting, or injured. The heart rate modifier gets added to when you’re healing or not sprinting. the heart slows down 1.5 times faster when healing than when catching your breath (not sprinting)
anyways, the way I determine healing, is by using this helpful little function here. the heart won’t slow down until you’ve healed at least a third of the damage you took, and if you get damaged again before you heal that third, the amount you have to heal stacks. after that, the heart will begin slowing down 1.5x faster than normal. Yes, the heart does stop when you’re dead. I even changed the ImageID on death, and made the heart colorshift to like a (0.15,0,0)
oh also I made it so characters don’t ready their guns until they shoot, and then after, they keep their gun ready for a different amount of time based on the size of the gun, before lowering their weapon again
Wow, that was a long post for not a whole lot of content. I know I didn’t need to put that much effort into the heart, and I know that everything I’ve shown here is really simple, but I’ve never scripted anything like this before, and it just feels good to know I’m improving. I had fun adding the heart just as a silly useless detail, and it just so happens to be fun to look at as well. For me, this was one of those rare projects that really makes you not want to stop working on it. (I’ve been doing this for 9 hours)
damage trigger:
External Mediaequip, shoot, reload triggers (also example of weapon animations)
External Mediasprinting heart behavior:
External Mediainjured heart behavior:
External Media