- Home /
Question by
Nasa98 · Feb 13, 2014 at 05:40 PM ·
2dinstantiatecoordinatesmove an object
Move a object to certain cordinates
Hey Im having a trouble figuring out ho to move a object to a certain coordinates because my spawner script instantiates a prefab and i cant have a transofrm in a prefab so. The question is: How i move a object to certain coordinates without a target object?
My spawner script is this:
var Enemies : GameObject[];
var DelayTime : float;
var TotalEnemies : int;
private var NextSpawn : float;
private var TotalSpawn : float;
function Update()
{
if(TotalSpawn >= TotalEnemies) return;
if(Time.time > NextSpawn)
{
NextSpawn = Time.time + DelayTime;
Instantiate(Enemies[Random.Range(0,Enemies.length)],transform.position,Quaternion.identit
TotalSpawn++;
}
}
Comment
Answer by nventimiglia · Feb 13, 2014 at 06:18 PM
You can pass a new Vector3() struct. When you ask for transform.position it returns a Vector3(). You do not need to go through transform first, any vector 3 will do. That said, using a target's transform is handy as you can set the position in the editor.
Answer by Nasa98 · Feb 14, 2014 at 07:24 AM
About the vector, ill try but with the target if I make a prefab of the player the target disappears!!