• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by importguru88 · Jul 14, 2016 at 04:18 AM · c#scripting problemerror

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();
             
             }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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);

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image importguru88 · Jul 14, 2016 at 05:04 AM 0
Share

Do you mean this way ?

public IEnumerator StartSinking ()

{

  StartCoroutine(Wait(3.0f));

}

avatar image jdean300 importguru88 · Jul 14, 2016 at 05:08 AM 0
Share

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

avatar image importguru88 jdean300 · Jul 14, 2016 at 05:13 AM 0
Share

I have the project it's small . If you want to take a look at it .

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

184 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

3 Days and I still can't figure out c# reflection, please help? Trying to use a protected Type and method. 1 Answer

If statement being ignored (Apparently) 2 Answers

Animation error (Last time I'm asking) 2 Answers

C# Cannot reference scripts on the FirstPersonCharacter 3 Answers

My Script Wont work? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges