Question by
RDG_Admin · Mar 15, 2021 at 03:37 PM ·
c#rotationrotation axis
Rotation issue when not in centre of scene?
Can somebody help me out here?! This is doing my head in. The rotation on my script is all kind of messed up.
Each of the green squares is a spawn point for this script. The spawn point for the set of blue boxes is in the center (0,1.5,0) of the scene. The other red boxes aren't. Each of them are rotated at a 20 degree angle and the blue set is what I'm expecting. The others seem to change the distance from the green spawn point depending on where they are in the scene which is causing issues.
Can anybody suggest how to fix this issue so the rotation result is the same as the blue set regardless of the location of the spawn point in the scene? The script is below...
productArray = new GameObject[productAmount];
for (int count = 0; count < productAmount; count++)
{
Vector3 Position = new Vector3(transform.position.x, transform.position.y, transform.position.z + count * distance);
Quaternion rotation = Quaternion.Euler(new Vector3(0, ProductAngle, 0));
GameObject pile = Instantiate(Product, rotation * Position, Quaternion.identity);
pile.transform.rotation = Quaternion.Euler(new Vector3(0, IndividualAngle, 0));
productArray[count] = pile;
}
unity-0.png
(146.6 kB)
Comment