首页 > 解决方案 > 我希望我的对象自动出现而不增加他的比例

问题描述

我希望我的对象自动出现而不增加他的比例,只是出现随机的地方而不是与硬币碰撞(就像被叠加)。这是硬币的生成器:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Object_Spawner : MonoBehaviour
{
    public GameObject player;
    public GameObject[] coins;

    private float coinSpawnTimer = 1.0f;

    // Update is called once per frame
    void Update()
    {
        coinSpawnTimer -= Time.deltaTime;

        if (coinSpawnTimer < 0.01)
        {
            SpawnCoins();
        }
    }
    void SpawnCoins()
    {
        Instantiate(coins[(Random.Range(0, coins.Length))], new Vector3(player.transform.position.x + 30, Random.Range(2, 8), 0), Quaternion.identity);
        coinSpawnTimer = Random.Range(1.0f, 3.0f);
    } 
}

标签: c#unity3d

解决方案


推荐阅读