Triggering Damage Visualization with external collision

nathanj

Active member
Hello,

Working on a Malbers integration for applying damage to the player.

I have the basic part working. All it does is when the AttackTrigger componet on the animal is enabled it checks of the collidiing object is a player, if it is it removes the damage amount. Pretty simple. This triggers the UI indicator but not the damage visualization ability on the player, which is kind of needed.

Code:
 private MAttackTrigger attackTrigger;

    private void Awake()
    {
        attackTrigger = gameObject.GetComponent<MAttackTrigger>();
    }
  
    public void OnTriggerEnter(Collider coll)
    {
        if (coll.gameObject.CompareTag("Player"))
        {
            CharacterHealth playerHealth = coll.gameObject.GetComponentInParent<CharacterHealth>();
            if (playerHealth) playerHealth.Damage(attackTrigger.statModifier.Value.Value);

        }
    }

Is there any way to modify the above code to trigger the damage visualization?

Much thanks,
Nathan
 
The GetDamageTypeIndex method of the DamageVisualization ability calculates the index which decides on the animation to play. The default ability requires attacker, position and direction / force of the damage. If these parameters are 0//null, the ability is not started.
You call the Damage method without attacker, position, and direction. So you have two options. You use a different Damage method, including all required parameters. Or you implement your own DamageVisualization that plays an animation also if position, direction, and attacker are not set.
 
Top