- Home /
Transform.position without Vector3?
Good day, I was making random spawner using 64 different locations and randomizer to decide in which place will my gameobject spawn. Here is most of my script:
...
var spawn64 : Transform;
var timer : float = 0.0;
var spawning : boolean = false;
var Fire : GameObject;
var bomb : AudioClip;
var location : Transform;
function Update () {
if (!spawning) {
timer += Time.deltaTime;
}
if(timer>=1) {
Spawn ();
}
}
function Spawn() {
spawning = true;
timer = 0;
var randomPick : int = Mathf.Abs(Random.Range(1,64));
if(randomPick == 0) {
location = spawn0;
}
else if(randomPick == 1) {
location = spawn1;
}
...
Fire.transform.position = location;//here is the error part
AudioClip.Play();
yield WaitForSeconds (3);
spawning = false;
...
I guess the problem is that I cannon tranform.position using transform, but how to fix it? Can I move gameobject using some other expression? Do I have to rewrite my whole script?
All help is much appreciated.
Comment
Best Answer
Answer by robertbu · Aug 12, 2013 at 07:21 AM
Location is a transform, so you have to do this:
Fire.transform.position = location.position;