Hi,
I'm developping a game with melee attacks. I want be able to controle when the weapon (sword) can damage ennemies during the animation.
1) At the start of the animation i want the damages are OFF because my character charges his sword attack, and i want prevent he hits ennemies in his back.
2) Then i want the damages are ON during the attack.
3) At the end i want the damages are OFF again to prevent damage if an ennemie touch the sword while the player animation ending.
On the meleeWeapon script, there is the variable canHitDelay which could do the job, but i need the delay depend of the animation and not depend of the weapon. Moreover this does not solve the 3).
I added events on the animation to know when damages should be active or inactive
And i created a class to received events
Im' stuck on the last part, make the weapon "inactive" when canDamage == false.
How can i do that ?
Thanks in advance for the help.
I'm developping a game with melee attacks. I want be able to controle when the weapon (sword) can damage ennemies during the animation.
1) At the start of the animation i want the damages are OFF because my character charges his sword attack, and i want prevent he hits ennemies in his back.
2) Then i want the damages are ON during the attack.
3) At the end i want the damages are OFF again to prevent damage if an ennemie touch the sword while the player animation ending.
On the meleeWeapon script, there is the variable canHitDelay which could do the job, but i need the delay depend of the animation and not depend of the weapon. Moreover this does not solve the 3).
I added events on the animation to know when damages should be active or inactive
And i created a class to received events
C#:
public class MeleeWeaponOverride : MonoBehaviour
{
private bool canDamage = false;
public void AttackDamageOn()
{
Debug.Log("Sword damage ON");
canDamage = true;
}
public void AttackDamageOff()
{
Debug.Log("Sword damage OFF");
canDamage = false;
}
}
Im' stuck on the last part, make the weapon "inactive" when canDamage == false.
How can i do that ?
Thanks in advance for the help.
Last edited: