i am developing 2d game…
I am creating gameobject with random posiyion…
Code which i have used is here:
function CreateRandomShip()
{
x = Random.Range(-4.00f , 4.00f);
z = -6.72f;
y = 8.0f;
enemy1Prefab.transform.position = new Vector3(x , y , z);
Instantiate(enemy1Prefab,enemy1Prefab.transform.position,enemy1Prefab.transform.rotation);
}
Now another script which i have created to translate in Down Direction is here:
function Update () {
currentSpeed = Random.Range(minSpeed , maxSpeed);
var amttomove : float = currentSpeed * Time.deltaTime;
transform.Translate(Vector3.down * amttomove , Space.World);
//transform.position = Vector3( Mathf.PingPong(Time.time,),transform.position.y,transform.position.z);
//transform.position.x = transform.position.x - enemyWiggle.x + Mathf.PingPong(Time.time * enemySpeed, enemyWiggle.x );
}
But I have tried this code but could not get result as all the objects are instantiated at same x position and able to move left and right…
But I want my gameobject to be moved left and right with that random x position…
So what do i need to do??
Please suggest me some solution regarding this issue…
Thanx in advance for your support and help…