When the enemy attacks the player health is not decreasing just displays as the default max value which is settled like 100
even hardcoding and passing numbers like stateMachine.Weapon.SetAttack(20); health just prints 100!
I have attached the health script to my player prefab, in another case the player effectively can decrease the health of the enemy the problem turns out to be I’m invincible now.
Am I missing something else?
my weapon logic:
the first log is from the enemy attacking
Enemy Attacking State script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyAttackingState : EnemyBaseState
{
private readonly int AttackHash = Animator.StringToHash("Attack");
private const float TransitionDuration = 0.1f;
public EnemyAttackingState(EnemyStateMachine stateMachine) : base(stateMachine) { }
public override void Enter()
{
stateMachine.Weapon.SetAttack(20);
stateMachine.Animator.CrossFadeInFixedTime(AttackHash, TransitionDuration);
}
public override void Tick(float deltaTime)
{
}
public override void Exit() { }
}