- Home /
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
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...
Answer by extremevertigo · Oct 10, 2012 at 05:01 PM
I am having a similar issue with that lab have you had any results?
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
Follow this Question
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