Question by
grasshopper01 · Apr 15, 2019 at 08:32 PM ·
transform3dpositiontransform.position
I'm permanently setting a GameObjects positions in Awake() but it keeps moving if I use the Cos function in calculating its position, anyone know why?
GameObject prefab = Resources.Load("char") as GameObject;
for (int i = 0; i < 20; i+=2)
{
GameObject go = Instantiate(prefab) as GameObject;
var x = radius * Mathf.Cos(deg[i] * Mathf.Deg2Rad);
var y = radius * Mathf.Sin(deg[i] * Mathf.Deg2Rad);
go.transform.position = new Vector3(x, y,0);
chars[i] = go;
}
Comment
I think I'd need some context to know what you are trying to achieve and where this snippet is running?
Is this the code in Awake() ?
You know you are stepping through the loop in increments of 2?
Is this 2D or 3D ?
Are you creating fixed positions or are you wanting to achieve random positions within a circle?