|
Post by hairgrow on Jan 8, 2021 19:12:26 GMT
So now I'm at the point where I'm working with Killables. Which essentially would be replacing my Damageable scripts. One of the features that my Damageable script had was the ability to filter hits, based on the angle/direction that the object was being hit. (This would be a great feature to add to Killables for general / VR purposes) I'm wanting to keep this feature, plus the ability to update the Max Hit Points. When I try to update the Max Hit Points on the Killable, I can't unless it's a KillerInt. Is there another way way to do this?
I see I can call AddHitPoints, but that seems to only update the Start Hit Points, leaving the Max Hit Points on the Killable object as is, which seems to throw off the actual Hit count. For instance, I have a script called Enemy Difficulty Level, which would set an enemies Max Hit Points. In this script, I'm calling AddHitPoints and setting it to 3, while the Max Hit Points on the Killable is currently set to 1. So when the Start Hit Points is updated to 3 on the enemy, and a Hit Point of 1 is registered from a projectile, it's actually counting as 2.
Are we suppose to update the Max Hit Points on the Killable at all or is this suppose to be set to an extremely High number upon Start?
|
|
|
Post by DarkTonic Dev on Jan 8, 2021 21:26:39 GMT
Updating Max Hit Points is like grabbing an "extra heart" in Zelda. It doesn't give you any extra life points, just extra capacity.
I don't think that's a feature I'd add (based on the angle of attack). You can call TakeDamage with a negative number to add health I believe.
You can use "KillableSubclass" to add and override things from Killable, but unfortunately no new fields will show since it's our Custom Inspector. If you grab extra fields from another component in KillableSubclass, then you can add that component as well and use its Inspector. You could override TakeDamage method to first check for attack angle before calling the base class TakeDamage.
I'd go that route.
AddHitPoints it working correctly.
|
|
|
Post by hairgrow on Jan 9, 2021 2:00:19 GMT
Lol. Love the Zelda reference. I literally saw the heart being added in my head from breath of the wild. Thanks for explaining. I've started doing exactly what you've mentioned with the TakeDamage. In my case, on the projectile, I set the Killables attacks points to zero, so my custom scripts can process the direction at which an enemy is being hit, and then supply the attack points via TakeDamage in the custom script.
Filtering the Direction/Angle at which an enemy is being hit allows me to dictate whether it can be hit from just the front, back, or all sides. As I've been getting into CGK I've noticed it contains a lot features, that I had to write myself previously. (Like the Knockback) So as I'm integrating it into my project, I just thought it would nice if the Angle Hit Filter was added into CGK natively versus me trying to strap it on. But as I'm learning more and more about CGK, it appears to have enough places to hook into for customizations.
|
|
|
Post by hairgrow on Jan 9, 2021 2:44:37 GMT
Follow up question. When creating a subclass from Killable, how would I grab fields from another component so it shows up in the inspector. I'm currently working with SpawnPrefab() for networking purposes and just saw what you were referring to regarding the custom inspector on subclass Killables.
|
|
|
Post by DarkTonic Dev on Jan 9, 2021 3:23:33 GMT
You're killable subclass can contain any code to override any methods in killable. so you can add code to mono behavior events such as on spawned with a getcomponent call to your other script.
|
|