Can someone tell me why this Java script from this tutorial makes a new object:
var thePrefab : GameObject;
function Start () {
var instance : GameObject = Instantiate(thePrefab, transform.position, transform.rotation);
}
I am Just learning Java script. I already know a litle C++ so I might be treating some code like C++, so just holler and tell me how to do it in Java.
Here are the things I do not understand about this script:
- What exactly is the command Instantiate
- Why Does setting the variable instance to Instantiate, run the command Instantiate. I would think it would set the value of instance to the text of the Instantiate command. So I could say some thing like "print var instance and it would show on screen, Instantiate(thePrefab, transform.position, transform.rotation)".
- I tried running the script with out setting the variable instance to Instantiate and it still made a new object, why then set variable instance to the instantiate command? I used the code:
var thePrefab : GameObject;
function Start() {
Instantiate(thePrefab, transform.position, transform.rotation);
}