- Home /
Question by
Dothackking · Jul 29, 2013 at 08:34 PM ·
c#coroutine
Can't get basic skill to work right(C#)
I would prefer not having advice about how I"m coding my skill, but instead, an explanation why my damage isn't reverting. What happens is: I use my "1" skill, it adds the damage I specified, but it never removes it.
void Update () {
if(Input.GetKeyDown ("1") && nextSkill < Time.time)
{
nextSkill += Time.time + aspd + 0.3f;
if(currentWepType == "1h sword")
{
animation.Play ("swordswing1");
previousdmg = dmg;
dmg += Mathf.FloorToInt(dmg * 0.3f);
wepWait ();
}
}
}
IEnumerator wepWait()
{
yield return new WaitForSeconds(1 * aspd);
dmg = previousdmg;
}
}
Comment
Best Answer
Answer by fafase · Jul 29, 2013 at 08:37 PM
In order to call a coroutine you need to use
StartCoroutine(Method());
In your case it goes:
void Update () {
if(Input.GetKeyDown ("1") && nextSkill < Time.time)
{
nextSkill += Time.time + aspd + 0.3f;
if(currentWepType == "1h sword")
{
animation.Play ("swordswing1");
previousdmg = dmg;
dmg += Mathf.FloorToInt(dmg * 0.3f);
StartCoroutine(wepWait ()); //HERE
}
}
}
IEnumerator wepWait()
{
yield return new WaitForSeconds(1 * aspd);
dmg = previousdmg;
}
}
Wow....derp. ive spent the last few days toying with blender and aparently that made me derp hard oncoroutines
Please accept answer if issue has been resolved. Vote up would be awesome too :D
+1
Sorry, I did accept but I was on my mobile and it aparentlyd idn't take.