hi
in my code there is already set positions of instantiated object brick but i need gap between clones of brick see the attached image
here is my code
var brick : GameObject;
function Start () {
for (var i = 0; i < Random.Range(2,4); i++){
var object = Instantiate(brick, Vector3(transform.position.x,-1.23,transform.position.z),Quaternion.identity);
object.transform.parent = transform;
}
}
hi thanks for you code ts working but why it is not instantiating from starting of the table see the below image [18941-test.jpg|18941]
– santosh810666there are two options: your transform.position.x != 0 at the beginning or it happens because of changing parent. when you link to another parent coordinates = parent coordinates + own coordinates
– nasa8hi here is my code which occurs error Operator '+' cannot be used with a left hand side of type 'UnityEngine.Transform' and a right hand side of type 'UnityEngine.Vector3' var brick : GameObject; var gap : float = 1.5; function Start () { for (var i = 0; i < Random.Range(2,4); i++) { var object = Instantiate(brick, Vector3(transform.position.x+gap*i,-1.23,transform.position.z),Quaternion.identity); object.transform.parent = transform+Vector3(1,transform.position.y,transform.position.z); } }
– santosh810666I'm not quite sure what you are trying to do with parent. and at least you can not add vector3 to transform - they are of different types
– nasa8my unity player is crashing while i am writing this code because platforms are instantiating dynamically and in here your specifying that only 3 platforms should be instantiated but i want to instantiate my brick to starting position of platform
– santosh810666