Hi guys,
I am trying to spawn objects in sine wave pattern and this is the script I am using:
// Use this for initialization
void Start () {
for(int i = 0; i<100; i++)
{
GameObject colNew = Instantiate(collectables[0], position, transform.rotation) as GameObject;
Vector3 colPos = colNew.transform.position;
position.y = SinePosition(colPos.x);
colNew.transform.position = position;
position.x++;
}
}
// Update is called once per frame
void Update () {
}
public float SinePosition(float x)
{
float y = 0.5f + 0.5f * Mathf.Sin(2 * Mathf.PI * x);
Debug.Log ("X: " + x + "Y: " + y);
return y;
}
There is a difference in y value, but it so small that it looks like they were spawned in a straight line. Could anyone help me out as this problem drives me crazy now?
Thanks in advance.