I'm trying to create a coin fountain burst.
I saw several people asking questions related to this but I can't seem to get it to work.
What I've done is:
public void CreateCoinBurst()
{
for (int i = 0; i < numberOfCoins; i++)
{
Rigidbody coinInstance = Instantiate(coinPrefab, spawner.position, spawner.rotation) as Rigidbody;
coinInstance.transform.rotation = Quaternion.Euler(Random.Range(0, 360), Random.Range(0, 360), 0);//This causes the coin to rotate around itself
Vector3 direction = new Vector3(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360));
Debug.Log("dir: " + direction.ToString());
coinInstance.AddForce(direction * force, ForceMode.Impulse);
}
}
The coins always shot in the same general direction and not really in a random direction.
I have also tried:
Vector3 direction = new Vector3(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360));
with different angles but all result in the coins poping in the same general direction.
What am I missing?
↧