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
0
Question by scr33ner · Aug 26, 2012 at 07:20 PM · errorgetcomponentconvertswitchenum

error BCE0022: Cannot convert error, please help

Hello all,

I'm relatively new to Unity & could use some help. I'll try to be as specific & concise as possible...

I have a pathNode.js script that has the following:

 enum PathInstruction{moveLeft=0, moveRight=1, moveStop=2, jumpAir=3}

 var pathInstruction = PathInstruction.moveStop;    

 function OnTriggerEnter (other : Collider)
 {

     if(other.tag == "enemy")

     {
         print("Goomba's here");
     }
 }

On a separate enemyGumba.js, I am trying to call pathInstruction & assign it to my gumbaState with the following lines:

 /*variables*/
 enum GumbaState{moveLeft=0, moveRight=1, moveStop=2, jumpAir=3, enemyDie=4, goHome=5}
 /*basic movements*/
 var gumbaState = GumbaState.moveLeft;
 :
 :
 function OnTriggerEnter (other : Collider)
 {
     /*when gumba collides with pathNode*/
     if(other.tag == "pathNode")
     {
         print(gumbaState);
         var linkToPathNode = other.GetComponent(pathNode);
         
         gumbaState = linkToPathNode.pathInstruction;
     }
 }



but- I am getting the error: BCE0022: Cannot convert 'PathInstruction' to 'GumbaState'. What can I do to correct this, do I need to instantiate gumbaState in a Start function?

Thanks in advance, scr33ner

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by scr33ner · Aug 26, 2012 at 09:11 PM

I did checks to make sure I'm able to get data from 'pathNode.js' & I am able to get the necessary data.

I just can't assign it to the other variable...

Does anyone know why this is?

thanks again...

Comment
Add comment · 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
0

Answer by scr33ner · Aug 28, 2012 at 04:03 PM

anyone have any thoughts???

Comment
Add comment · 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
0

Answer by extremevertigo · Oct 10, 2012 at 05:01 PM

I am having a similar issue with that lab have you had any results?

Comment
Add comment · Show 1 · 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 scr33ner · Oct 10, 2012 at 05:40 PM 0
Share

Need to convert enum to int so the values can be compared.

I've not worked on the lab to test it- but this is the e-mail I got from Walkerboystudios:

You can do a comparison or switch in the collider state or additional function call. function OnTriggerEnter (other : Collider) { /when gumba collides with pathNode/ if(other.tag == "pathNode") { // check pathnode state // if pathnode state is moveLeft, // set gumbaState to moveLeft

Do this for each one of the states. That will convert it over and let you check each on and assign the correct state between the two.

Also, you can covert the enum to a int and compare ints. http://forum.unity3d.com/threads/125992-Error-when-making-one-enum-equal-to-another

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

9 People are following this question.

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

Related Questions

Enum switch statement error 2 Answers

BCE0051 Error 1 Answer

Enum is thought to be a float? 2 Answers

Particle circle HELP 1 Answer

After switching platforms, script assets purchased from store don't compile and reference to them is lost 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