So, I just found out that in WebGL you can’t use strings to access things in get component. ( WHAT A FOOL I WAS FOR REMOVING PRAGMA STRICT!!!)
rock.GetComponent("RockScript").hardness = 10;
//This doesn't work in WebGL
Now I have to go change like 100 errors in my code. But there’s one big one that I am having trouble finding a practical solution to.
static function findscript (playern : GameObject) {
if(playern.name == "Xander"){
return "move";
}else if(playern.name == "Danny"){
return "move1";
}
}
I run this function a lot. I always use it like this
player.GetComponent(seek.findscript(player)).dead = true;
Essentially, both players have 2 different scripts with the same variables (no, I cannot make them into the same script). I simply take the game object and, using the name of the player, return the respective name of that player’s script. This way, I don’t have to do a long if statement before every time I want to access one of the move scripts.
But now I need to put a class into GetComponent, not a string. Sadly,
static function findscript (playern : GameObject) {
if(playern.name == "Xander"){
return move;
}else if(playern.name == "Danny"){
return move1;
}
}
Doesn’t work. I get a “type could not be resolved because of a cycle.” error. I’m not the best coder, but to my knowledge, I think this means I the function needs to return the same class each time.
This is a bother because the whole point of this function is to return a different function for each input.
Any ideas how I can practically deal with all of these errors? Thanks, sorry this was such a long question.