Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
-1
Question by gigirs50 · Jan 31, 2014 at 12:57 PM ·

Cannot implicitly convert type `Movement.Start46' to `System.Collections.Generic.IEnumerator

 using Boo.Lang;
 using Boo.Lang.Runtime;
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Runtime.CompilerServices;
 using UnityEngine;
 [Serializable]
 public class Movement : MonoBehaviour
 {
     [CompilerGenerated]
     [Serializable]
     internal sealed class Start46 : GenericGenerator<object>
     {
         [Serializable]
         internal sealed class self_ : GenericGeneratorEnumerator<object>, IEnumerator
         {
             internal float t47;
             internal Movement self_48;
             public self_ (Movement self_)
             {
                 self_48 = self_;
             }
             public bool movenext()
             {
                  int varBG0;
                  switch (this._state)
                  {
                       case 0:
                       {  
                            Lb1_BJ:
                            break;
                       }
                       case 1:
                       {
                            varBG0 = 0;
                            return varBG0 !=0;
 
                       }
                       case 2:
                       {
                            this.t47 += Time.deltaTime;
                            if (Input.GetKeyDown(KeyCode.Backspace))
                            {
                                  this.self_48.spaceTapped = true;
                                  goto Lb1_GM;
                            }
                            this.self_48.spaceTapped = false;
                            goto Lb1_GM;
                       }
                       case 3:
                       {
                            goto Lb1_KA;
                       }
                  }
                  goto Lb1_BJ; 
                  Lb1_GM:
                  if (this.t47 >= this.self_48.dubleTapDelay)
                  {
                       Lb1_OT:
                       varBG0 = (this.yieldDefault(3) ? 1 : 0);
                       return varBG0 !=0;
                  }
                  varBG0 = (this.yieldDefault(2) ? 1 : 0);
                  return varBG0 != 0;
                  Lb1_KA:
                  if (Input.GetKeyDown(KeyCode.Backspace))
                  {
                       this.t47 = (float)0;
                       goto Lb1_GM;
                  }
                  goto Lb1_OT;
                  return varBG0 != 0;
              }
         }
         internal Movement self_49;
         public Start46(Movement self_)
         {
             this.self_49 = self_;
         }
         public override IEnumerator<object> GetEnumerator()
         {
             return new Movement.Start46.self_(this.self_49);
         }
     }
     public float rotationSpeed;
     public float walkSpeed;
     public float flySpeed;
     public float swoopSpeed;
     public float gravity;
     private float yRot;
     private float xRot;
     public Transform body;
     private int PowerUp;
     private object onGround;
     public Transform teleportBody;
     public float xMin;
     public float xMax;
     public float doubleTapDelay;
     private int count;
     private bool spaceTapped;
     private bool flyState;
     public Movement()
     {
         this.rotationSpeed = (float)10;
         this.walkSpeed = (float)7;
         this.flySpeed = (float)20;
         this.swoopSpeed = (float)50;
         this.gravity = (float)50;
         this.doubleTapDelay = 0.2f;
     }
     public IEnumerator Start()
     {
         return new Movement.Start46(this).GetEnumerator();
     }
     public void Update()
     {
         Screen.lockCursor = true;
         if (Input.GetKeyDown(KeyCode.Escape))
         {
             Screen.lockCursor = false;
         }
         Vector3 a = this.transform.TransformDirection(Vector3.forward);
         Vector3 a2 = this.transform.TransformDirection(Vector3.right);
         Vector3 a3 = this.transform.TransformDirection(Vector3.left);
         Vector3 a4 = this.transform.TransformDirection(Vector3.back);
         Vector3 a5 = this.transform.TransformDirection(Vector3.down);
         Vector3 a6 = this.transform.TransformDirection(Vector3.up);
         CharacterController characterController = (CharacterController)this.GetComponent(typeof(CharacterController));
         if (Screen.lockCursor)
         {
             this.onGround = characterController.isGrounded;
             this.animation["walk_forward"].speed = this.walkSpeed / (float)4;
             this.animation["walk_backward"].speed = this.walkSpeed / (float)4;
             if (this.PowerUp == 0)
             {
                 if (Input.GetAxis("Vertical") > (float)0)
                 {
                     if (RuntimeServices.ToBool(this.onGround))
                     {
                         this.animation.Play("walk_forward", PlayMode.StopAll);
                     }
                     if (this.flyState)
                     {
                         this.animation.Play("fly_forward", PlayMode.StopAll);
                         characterController.Move(a * (this.flySpeed * Input.GetAxis("Vertical")) * Time.deltaTime);
                     }
                     characterController.Move(a * (this.walkSpeed * Input.GetAxis("Vertical")) * Time.deltaTime);
                 }
                 else
                 {
                     this.animation.CrossFade("idle");
                 }
                 if (Input.GetAxis("Vertical") < (float)0)
                 {
                     if (this.flyState)
                     {
                         this.animation.Play("fly_backward", PlayMode.StopAll);
                         characterController.Move(a4 * (-this.flySpeed * Input.GetAxis("Vertical")) * Time.deltaTime);
                     }
                     this.animation.CrossFade("walk_backward");
                     characterController.Move(a4 * (-this.walkSpeed * Input.GetAxis("Vertical")) * Time.deltaTime);
                 }
                 else
                 {
                     this.animation.CrossFade("idle");
                 }
                 if (Input.GetAxis("Horizontal") > (float)0)
                 {
                     if (this.flyState && Input.GetAxis("Vertical") == (float)0)
                     {
                         this.animation.Play("fly_right", PlayMode.StopAll);
                         characterController.Move(a2 * (this.flySpeed * Input.GetAxis("Horizontal")) * Time.deltaTime);
                     }
                     this.animation.CrossFade("walk_forward");
                     characterController.Move(a2 * (this.walkSpeed * Input.GetAxis("Horizontal")) * Time.deltaTime);
                 }
                 else
                 {
                     if (Input.GetAxis("Horizontal") < (float)0)
                     {
                         if (this.flyState && Input.GetAxis("Vertical") == (float)0)
                         {
                             this.animation.Play("fly_left", PlayMode.StopAll);
                             characterController.Move(a3 * (-this.flySpeed * Input.GetAxis("Horizontal")) * Time.deltaTime);
                         }
                         this.animation.CrossFade("walk_forward");
                         characterController.Move(a3 * (-this.walkSpeed * Input.GetAxis("Horizontal")) * Time.deltaTime);
                     }
                 }
             }
             if (Input.GetAxis("Mouse X") != (float)0)
             {
                 this.yRot += (float)10 * Input.GetAxis("Mouse X");
             }
             if (Input.GetAxis("Mouse Y") != (float)0 && this.flyState)
             {
                 this.xRot -= (float)5 * Input.GetAxis("Mouse Y");
             }
             else
             {
                 if (RuntimeServices.ToBool(this.onGround))
                 {
                     this.xRot = (float)0;
                 }
             }
             if (this.xRot > this.xMax)
             {
                 this.xRot = this.xMax;
             }
             else
             {
                 if (this.xRot < this.xMin)
                 {
                     this.xRot = this.xMin;
                 }
             }
             this.transform.rotation = Quaternion.Euler(this.xRot, this.yRot, (float)0);
             characterController.Move(a5 * this.gravity * Time.deltaTime);
             if (Input.GetKeyDown(KeyCode.E) && Input.GetAxis("Horizontal") == (float)0 && Input.GetAxis("Vertical") == (float)0 && Input.GetAxis("GoUp") == (float)0)
             {
                 this.PowerUp = 1;
                 this.animation.Play("powerup0", PlayMode.StopAll);
             }
             else
             {
                 if (Input.GetKeyUp(KeyCode.E))
                 {
                     this.animation.CrossFade("idle");
                     this.PowerUp = 0;
                 }
             }
             if (this.PowerUp == 0 && RuntimeServices.ToBool(this.onGround) && (Input.GetKeyDown(KeyCode.F) || this.spaceTapped) && !this.flyState)
             {
                 this.gravity = (float)0;
                 this.flyState = true;
             }
             if (this.flyState)
             {
                 if (Input.GetKeyDown(KeyCode.F))
                 {
                     this.flyState = false;
                 }
                 this.animation.CrossFade("fly_idle");
                 this.gravity = (float)0;
             }
             else
             {
                 if (!this.flyState)
                 {
                     this.gravity = (float)50;
                 }
             }
             if (Input.GetAxis("GoUp") != (float)0 && this.flyState && Input.GetAxis("Horizontal") == (float)0 && Input.GetAxis("Vertical") == (float)0)
             {
                 this.animation.Play("fly_up", PlayMode.StopAll);
                 characterController.Move(a6 * (this.flySpeed * Input.GetAxis("GoUp")) * Time.deltaTime);
             }
             else
             {
                 this.animation.CrossFade("fly_idle");
             }
             if (Input.GetKeyDown(KeyCode.Mouse2))
             {
                 if (this.flyState)
                 {
                     this.flySpeed = this.swoopSpeed;
                 }
             }
             else
             {
                 if (Input.GetKeyUp(KeyCode.Mouse2))
                 {
                     this.flySpeed = (float)20;
                 }
             }
         }
     }
     public void LateUpdate()
     {
         if (GameObject.FindGameObjectWithTag("Player") && !this.flyState)
         {
             if (Input.GetAxis("Vertical") > (float)0)
             {
                 if (Input.GetAxis("Horizontal") > (float)0)
                 {
                     int int_ = 45;
                     Vector3 localEulerAngles = this.body.localEulerAngles;
                     float sngl_ = localEulerAngles.y = (float)int_;
                     Vector3 vector = this.body.localEulerAngles = localEulerAngles;
                 }
                 else
                 {
                     if (Input.GetAxis("Horizontal") < (float)0)
                     {
                         int int_2 = -45;
                         Vector3 localEulerAngles2 = this.body.localEulerAngles;
                         float sngl_2 = localEulerAngles2.y = (float)int_2;
                         Vector3 vector2 = this.body.localEulerAngles = localEulerAngles2;
                     }
                 }
             }
             if (Input.GetAxis("Horizontal") > (float)0 && Input.GetAxis("Vertical") == (float)0)
             {
                 int int_3 = 90;
                 Vector3 localEulerAngles3 = this.body.localEulerAngles;
                 float sngl_3 = localEulerAngles3.y = (float)int_3;
                 Vector3 vector3 = this.body.localEulerAngles = localEulerAngles3;
             }
             else
             {
                 if (Input.GetAxis("Horizontal") < (float)0 && Input.GetAxis("Vertical") == (float)0)
                 {
                     int int_4 = -90;
                     Vector3 localEulerAngles4 = this.body.localEulerAngles;
                     float sngl_4 = localEulerAngles4.y = (float)int_4;
                     Vector3 vector4 = this.body.localEulerAngles = localEulerAngles4;
                 }
             }
         }
         if (this.PowerUp == 1)
         {
             if (RuntimeServices.ToBool(this.onGround))
             {
                 this.animation.Play("powerup", PlayMode.StopAll);
             }
             if (this.flyState)
             {
                 this.animation.Play("fly_powerup", PlayMode.StopAll);
             }
         }
     }
     public void Main()
     {
     }
 }
 
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

Answer by Bunny83 · Jan 31, 2014 at 01:23 PM

What's the point of defining your own generator which virtually does nothing? Your Start46 class has no logic at all and your error is in GetEnumerator. The class creates a new instance of itself but you can't return it in GetEnumerator since your Start46 is an IEnumerable, not an IEnumerator.

What are you trying to do here?

Is it possible that you tried decompiling a foreign class you don't own? To me it looks like this was originally a UnityScript class (due to the boo references) Coroutines are usually not properly decompiled.

If you try to steal other people's work you're definitely wrong here.

edit
I won't fix your whole script, i don't even try, but the goto in line 56 is probably wrong. Your coroutine probably was something like thid:

 IEnumerator Start()
 {
     float t = 0;
     while(true)
     {
         if (t >= dubleTapDelay)
         {
             if (Input.GetKeyDown(KeyCode.Backspace))
                 t = 0;
         }
         else
         {
             t += Time.deltaTime;
             if (Input.GetKeyDown(KeyCode.Backspace))
                 spaceTapped = true;
             else
                 spaceTapped = false;
         }
         yield return null;
     }
 }

As far as i can tell it was a simple double-tap detection for the backspace key. I just like to add that this implementation could cause "spaceTapped" to stay true when the second tap was right before the timeout. It's usually better to set it only to true in the coroutine and reset it to false when you've "used" the state / event in Update.

Comment
Add comment · Show 4 · 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 gigirs50 · Jan 31, 2014 at 03:05 PM 0
Share

yes,I decompiled this script, I wanted the code to one of my old project that is dead, there is a way to make it work properly?thanks

avatar image Bunny83 · Jan 31, 2014 at 03:45 PM 0
Share

No, coroutines usually can't be decompiled since the compiler usually uses goto instructions inside the IEnumerator which can't be proberly decompiled by most high-level-language decompilers. When you decompile to IL the missing inner class would be there, but you have to be able to "read" IL which is a pain in the a**

avatar image gigirs50 · Feb 02, 2014 at 09:47 AM 0
Share

script update,I was able to decompile goto instructions with another decompiler in c #, but now other 6 errors

avatar image Bunny83 · Feb 03, 2014 at 01:47 PM 0
Share

I've updated my answer but i won't "fixing" this any further. If it really is your script you should understand it and be able to fix it yourself. Just remove the whole internal class "Start46" and replace the Start method with $$anonymous$$e.

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.

Follow this Question

Answers Answers and Comments

20 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

Related Questions

A node in a childnode? 1 Answer

Upgrading Unity 3.2 Problems 2 Answers

Prevent colliders intersecting. 1 Answer

How to make an instantiated enemy to translate to a point first and then to lookAt the player ??? 2 Answers

Can I use Unity to create a Facebook Game? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges