I’m having a huge headache which I can’t seem to find the right answer for (in JS).
var a : GameObject; // or been made somewhere else...
var b : GameObject;
b = Instantiate(a, transform.position, Quaternion.identity);
Then I get an error in the console:
Cannot convert UnityEngine.Object to UnityEngine.GameObject
so I can only guess that the ‘object’ which Instantiate accepts makes the returning value an object, but how to do change it as I need the returning value to be a GameObject.
I tested this by changing [ var b : Object ] and it works, however breaks later on in the code.
Well now I get node unityengine.object.instantiate(self.a, self.get_transform().get_position(), Quaternion.get_identity())[of UnityEngine.GameObject] has not been correctly processed.
It’s always necessary in C#, but only necessary in JavaScript when you need strict typing, which of course you do, in this forum section, for the time being. It’s a good practice to get into, in my opinion. Someday we’ll surely have dynamic typing available for iOS, but I’ll keep using strict typing. It doesn’t take much extra time to type, and it makes the code more clear to me. Countless others agree and disagree!