Hello, I don’t know what is wrong, there are three things at the moment.
#1 I have a Special Move ability that right now does not call any damage but looks like the Animation is causing it. When I use the same Animation that I use for Action Items it doesn’t seem to cause damage.
#2 At one point the cooldown for the Special Move worked, but now I don’t know if adding the Animation and other stuff I missed placed it in the script, can’t use when out of Spirit works tho.
#3 With the wolfs the Brown one has the Attack Animation from the asset that came with it, but it causes no damage. The Gray wolf has the default Animation for an attack that the humanoids have and it causes damage. Don’t know if its the Animation or I have to code something special for it.
the code for #1
public class Spirit : MonoBehaviour, ISaveable
{
[SerializeField] float regenSpiritPercent = 50;
[SerializeField] float coolDown = 5;
[SerializeField] float SpiritCost = 10;
[SerializeField] float buffEffectTime = 5;
[SerializeField] float bonuesEffectAmount = 5;
[SerializeField] GameObject spiriteffect = null;
LazyValue<float> SpiritPoints;
// for items that refill Spirit
public void GainSpirit(float ISpiritAmount)
{
SpiritPoints.value = Mathf.Min(SpiritPoints.value + ISpiritAmount, GetMaxSpiritPoints());
GainSpiritEffect();
}
private void GainSpiritEffect()
{
Instantiate(spiriteffect, transform);
}
private void Awake()
{
SpiritPoints = new LazyValue<float>(GetInitialSpirit);
}
private void Start()
{
SpiritPoints.ForceInit();
}
// for Special Moves
private void Update()
{
coolDown -= Time.deltaTime;
KeySpecialMove();
}
private void KeySpecialMove()
{
if (Input.GetKeyDown(KeyCode.Space) && SpiritPoints.value >= SpiritCost)
{
activeAblility();
SpecialMoveAimation();
}
}
private void activeAblility()
{
if (coolDown > 0) return;
ReduceSpirit();
UseAbility();
StartCoolDown();
}
private void SpecialMoveAimation()
{
GetComponent<Animator>().SetTrigger("Special Move");
GetComponent<Animator>().ResetTrigger("Attack");
}
private void ReduceSpirit()
{
print("lost SP");
SpiritPoints.value = Mathf.Max(SpiritPoints.value - SpiritCost, 0);
}
// for each type of element ability
protected virtual void UseAbility()
{
print("damage");
}
public void StartCoolDown()
{
coolDown = 0;
GetComponent<Animator>().ResetTrigger("Special Move");
print("CoolDown");
}