- Home /
Health.cs(331,22): error CS1624: The body of `Opsive.ThirdPersonController.Health.DieLocal(UnityEngine.Vector3, UnityEngine.Vector3)' cannot be an iterator block because `void' is not an iterator interface type
I have legacy animations . I try to make the death animation play late because of the animation frame is not keep up when its deactivating the object. I need to start a start a Coroutine some where on this network health script. The script is long . I will only show you the codes where the errors are at .
I try to code and I gotten two of the same errors :
Assets/Third Person Controller/Scripts/Health.cs(331,22): error CS1624: The body of Opsive.ThirdPersonController.Health.DieLocal(UnityEngine.Vector3, UnityEngine.Vector3)' cannot be an iterator block because
void' is not an iterator interface type
Assets/Third Person Controller/Scripts/Health.cs(56,21): error CS1624: The body of Opsive.ThirdPersonController.Health.StartSinking()' cannot be an iterator block because
void' is not an iterator interface type
public void StartSinking()
{
isSinking = true;
print("Starting " + Time.time);
yield return StartCoroutine(WaitAndPrint(2.0F));
print("Done " + Time.time);
}
// Deactivate the object if requested.
if (m_DeactivateOnDeath) {
Scheduler.Schedule(m_DeactivateOnDeathDelay, Deactivate);
yield return null (.05);
this.animation.Play("die");
GetComponent<AudioSource>().Play();
}
Answer by jdean300 · Jul 14, 2016 at 04:41 AM
Coroutines should return IEnumerator:
public IEnumerator StartSinking()
{
//Code goes here
}
I also don't think yield return null (.05);
is going to work. If you're trying to wait for .05 seconds then use yield return new WaitForSeconds(.05f);
Do you mean this way ?
public IEnumerator StartSinking ()
{
StartCoroutine(Wait(3.0f));
}
No, I mean in the if statement you posted. yield return null (.05);
shouldn't even compile. Let me check real quick.... yeah that doesn't compile.
I'm not sure what you are trying to do with the (.05), but if it is to wait for .05 seconds then continue the coroutine then you want`yield return new WaitForSeconds(.05f);`.
Also, unless you have defined a Wait
coroutine yourself, Unity does not have one. You probably mean to use WaitForSeconds
I have the project it's small . If you want to take a look at it .