Hey guys, I thought this would be relatively simple, but can’t seem to grasp it.
I have:
if (GUI.Button (Rect (Screen.width/2-50, 125, 100, 30), "Floor")) {
var instance : GameObject = Instantiate(Resources.Load("Floor", GameObject));
}
and tried
instance.transform.position = positionvariable;
and that did not work. Any ideas? I tried finding online but got nothing! Thanks ahead of time!
Your variable instance
is declared inside the if-statement. Therefore, it is not available outside its scope.
At least that’s how it works with C#, I’m not sure whether the behaviour is the same with UnityScript.
Yeah that should work perfectly fine. This shouldn’t make a difference but try setting the position when you instantiate it via
Instantiate(Resources.Load("Floor", GameObject), positionvariable, Quaternion.Identity);