I have created a fully armored guardian character. Ideally, I’d like the hero to be able to blow away the armor the - or to be honest to require the armor be blown off before the guardian can take any real damage at all.
I set it up w/mesh colliders (convex) but that can really slow things down and I scrapped that approach, going with discreet simple colliders on individual armor parts.
When I shoot the guardian, I can w/a lot of heartache and tons of ammo, generally blow away bits of armor but its rather unreliable. Grenade/Rocket attacks, of course, do a better job.
I would dearly LOVE some suggestions on a best approach here.
ALSO :: I’ve discovered that if my Player character appraoches too close to the armored Guardian that everything has a tendency to lock up ← not remotely sure what;s causing that behavior.
No I am pretty convinced that it is a scripting issue.
For example, I adapted the damage scripts used for objects/characters from the FPS tutorial like follows:
var armorPoints = 20.0;
var deadReplacement : Transform;
var ArmorSound : AudioClip;
function ApplyDamage (damage : float) {
// We already have less than 0 armorPoints, maybe we got killed already?
if (armorPoints <= 0.0){
return;
}
armorPoints -= damage;
if (armorPoints <= 0.0)
{
RemoveArmor();
}
}
function RemoveArmor () {
// Play a dying audio clip
if (ArmorSound)
AudioSource.PlayClipAtPoint(ArmorSound, transform.position);
yield WaitForSeconds(3);
renderer.enabled = false;
}
static function CopyTransformsRecurse (src : Transform, dst : Transform) {
dst.position = src.position;
dst.rotation = src.rotation;
for (var child : Transform in dst) {
// Match the transform with the same name
var curSrc = src.Find(child.name);
if (curSrc)
CopyTransformsRecurse(curSrc, child);
}
}
Its pretty straight-forward and does work (as mentioned above) but the accuracy of the individual collider zones appears spotty - partially why I was hoping for some recommendations.
And of course - the issue of having Unity hang when approaching the now de-armored Guardian is a show stopper. Again – hoping this is something I can avoid via scripting.
I found out what is causing Unity to lock up – the colliders on my vanquished enemy do not disappear/move when the death animation plays, leaving them in the enemy’s original position.
Watching from inside the inspector shows me this::