Damage visualization almost never get triggered

Lavos

Member
I was able to add damage visualization to my main character and it works well but it does not seem to work for my AI agent character.
The ability index parameter is almost never set to 10 as it should be.
Sometimes, it is triggered for no clear reason and I can see the hit animation as expected, but it is very rare and I do not know how to reproduce it...
Could you please help me?
 
I'm not exactly clear on how you're using it - the agent is damaging your character and the visualization is not appearing?
 
Actually, damage visualization works fine for the main character. However when the character attacks the agent, the agent is not damaged and the hit visualization does not appear either. Sometimes it works but it is very rare (like every 40 strikes).
 
So really the issue is that the enemy is not getting damaged by the character when it should.

First check the colliders of the character's sword (watch it during runtime to make sure the swinging animation isn't causing the sword's collider to go somewhere unexpected) and the enemy's CapsuleCollider. Also check your MeleeWeapon's Impact Layers.
 
Everything seems to be ok with the colliders.

NoDamage6.gif

Also I don't think anything is wrong with the impact layers of the melee weapon.

1612977715036.png
 
Can you place a breakpoint within MeleeWeapon.OnCollision to ensure the collision is registered?
 
I could not find any OnCollision method in my MeleeWeapon class, so I placed a breakpoint within the HitCollider method. The result seems pretty consistent with what I see in the scene: HitCollider is almost never called except very rarely (every 40 strikes or so).
 
Chances are the collider is never overlapping that frame. You can try increasing the width of the collider on your sword.
 
Can you step through MeleeWeapon.UseItemUpdate to see why hitCount is returning 0? With a box collider it should return a positive value here:

Code:
                    hitCount = Physics.OverlapBoxNonAlloc(hitboxTransform.TransformPoint(boxCollider.center), Vector3.Scale(boxCollider.size, boxCollider.transform.lossyScale) / 2, m_CollidersHit, hitboxTransform.rotation, m_ImpactLayers, m_TriggerInteraction);
 
Done. Actually the line you copied is almost never reached but when it is, it returns 1 and everything works fine.
So I think the problem must be before that line. I believe the line is never reached because of the MeleeHitbox's CanUse method which always returns false on the following line :

1613055071798.png

Unfortunately, I don't understand this part very well. Could this be the source of the problem?
 
Ok I finally fixed it by enabling the Use Complete Event --> Wait for Animation Event instead of using a duration.
I don't know if that makes sense to you... :S
Thanks a lot for your time.
 
Top