Not quite there.
Let’s examine the Instantiate command:
Instantiate (Object original, Vector3 position, Quaternion rotation)
So there are three things: Object, Vector3, Quaternion. These can be referenced several different ways: from a variable, hardcoded, computed some way, beamed in by thought control…wait, scratch that, OTEE hasn’t finished the ESP plugin yet.
The point is, you need an object, then you need to tell it where to be, then you need to tell it how to rotate. (Although, you can leave out the position and rotation, and just use the object, in which case it will clone that object and keep the same position and rotation.)
Commonly you instantiate gameObjects, but really you can instantiate anything, including scripts. Let’s stick to gameObjects though. Usually you’d probably make a variable to hold the gameObject, which you’ve done by using “var spawnage : GameObject;” So now “spawnage” is a gameObject and can be used in Instantiate: “Instantiate (spawnage);” would just clone it, for example.
For the position, that’s a Vector3, which is the location in XYZ space. This can be from a variable, or hardcoded, or whatever. For example, if you always wanted “spawnage” to appear at location 10, 50, 90, you could write “Instantiate (spawnage, Vector3(10, 50, 90), Quaternion.identity);”. It might be better to use a variable, though, to make it easier to change without recompiling the script…have “var theLocation : Vector3;” at the top of your script, which makes “theLocation” a variable of type Vector3. So now you can enter whatever values you want for the XYZ coordinates in the inspector, and then do: “Instantiate (spawnage, theLocation, Quaternion.identity);” If you use “transform.position” for the location, it uses the Vector3 of whatever location where the object is that the script is attached to. So “Instantiate (spawnage, transform.position, Quaternion.identity);” would make “spawnage” appear at the same position as the object with the collision script on it.
The rotation is similar to the position, but it’s a quaternion. Using “Quaternion.identity” means basically no rotation. You could have “var theRotation : Quaternion;” if you wanted to specify a particular quaternion in the inspector (assuming you actually understand them; I don’t.
). Then you’d use “Instantiate (spawnage, theLocation, theRotation);” Again, using “transform.rotation” for the rotation uses whatever rotation of the object that the script is attached to.
One way to specify a rotation without messing directly with quaternions would be to do, say, “var spawnClone = Instantiate (spawnage, theLocation, Quaternion.identity);” followed by “spawnClone.transform.Rotate(Vector3.up * 90);” which would make a clone of the “spawnage” gameObject and then rotate it around its up axis (or Y axis) by 90 degrees.
Hope that helps! And that I didn’t make any typos in the code!
–Eric