コード例 #1
0
ファイル: Spawner.cs プロジェクト: tugaykansu/BallAction
    void InstantiatePeriodically()
    {
        Vector2    rand       = Random.insideUnitCircle * 6;
        Vector3    spawnPoint = spawnCenter + new Vector3(rand.x, 0, rand.y);
        GameObject ball       = Instantiate(prefab, spawnPoint, Quaternion.identity);

        Rigidbody   rb  = ball.GetComponent <Rigidbody>();
        Transform   tra = ball.GetComponent <Transform>();
        MoveToPoint mtp = ball.GetComponent <MoveToPoint>();

        tra.localScale *= Random.Range(0.5f, 2.0f);
        rb.mass        *= Random.Range(0.5f, 2.0f);
        mtp.ScaleMovePower(Random.Range(0.5f, 2.0f));
        mtp.ScaleMaxAngularVelocity(Random.Range(0.5f, 2.0f));


        Invoke("InstantiatePeriodically", period);
    }