Rotate Spawnpoint running into errors

I dont know why coding this is so difficult! i feel dumb!

I want to rotate the spawnpoint inside a loop so that it instantiates 10 gamobjects in different directions. Am i mixing up quaternions and eulerangles? (i tried so many versions of the “spawnpoint.transform.Rotate” that by now it probably has a $yntax error.

var gridX = 1; 
var gridY = 8; 
var spacing = 1.0; 
var blocks : GameObject[];
private var rot : Quaternion;
var sp : GameObject;

sp = GameObject.Find("spawnpoint");

function Start () { 
for (var y = 0; y < gridY; y++) { 

sp.transform.RotateAround(Vector3.up,20*y);
 for (var x = 0; x < gridX; x++) { 



rot.eulerAngles = Vector3(0,0,0);//you can rotate this at 45 etc and also mult byx
 var ino = Instantiate(blocks[Random.Range(0, blocks.Length)], Vector3 (x-4, 6, 4) * spacing, rot);
 ino.transform.localScale += Vector3((Mathf.Pow(Random.Range(0,1.7), 4)),(Mathf.Pow(Random.Range(0,1.6), 5)),(Mathf.Pow(Random.Range(0,1.7), 4)));


  }
 } 
} 

EDIT= Apparent Answer:

the instantiation command doesnt seem to have any relation to the spawnpoint position and rotation unless you manually calculate the new global positions and rotations as functions of the spawnpoint rotation and position. ??? i thought that if you just rotate a spawnpoint you can have objects instantiate in positions relative to it, but no!!!

you have to do something like this:…?

1 Answer

1

I hope I’m not underestimating your problem, but I think that you just need

spawnpoint.transform.RotateAround(Vector3.up,myangle);

and be absolutely sure that

objRot = spawnpoint.transform.rotation;

since as of now you’re setting all of ino’s rotations to 0 eulers.

Well the downgrade thing might not be of help, however: assure that sp = GameObject.Find("spawnpoint"); is not returning null, before sp.transform besides, I don't remember if you can call RotateAround as a procedure. In C# you need to declare a new transform, copy sp.transform into it, rotatearound the new transform and finally assign sp.transform = newtransform.

–

Glad you sorted it out :)

–