::Ah right, sorry about that, forgot the forum was locked. For the fix it’ll be;
In the PlayerController.cs put the castOrHealTimer
in the CastSpell()
method instead of GetInputs()
. This relocation ensures that the timer doesn’t reset when you release the Cast/Heal button before CastSpell()
is called.
void GetInputs()
{
xAxis = Input.GetAxisRaw("Horizontal");
yAxis = Input.GetAxisRaw("Vertical");
attack = Input.GetButtonDown("Attack");
if (Input.GetButton("Cast/Heal"))
{
castOrHealTimer += Time.deltaTime;
}
else
{
castOrHealTimer = 0;
}
}
void CastSpell()
{
if (Input.GetButtonUp("Cast/Heal") && castOrHealTimer <= 0.05f && timeSinceCast >= timeBetweenCast && Mana >= manaSpellCost)
{
pState.casting = true;
timeSinceCast = 0;
StartCoroutine(CastCoroutine());
}
else
{
timeSinceCast += Time.deltaTime;
}
if (!Input.GetButton("Cast/Heal"))
{
castOrHealTimer = 0;
}
if(Grounded())
{
//disable downspell if on the ground
downSpellFireball.SetActive(false);
}
//if down spell is active, force player down until grounded
if(downSpellFireball.activeInHierarchy)
{
rb.velocity += downSpellForce * Vector2.down;
}
}