硬币出现在其他物体上,玩家无法触及它们

时间:2019-05-04 13:31:36

标签: unity3d game-development

我的Object_Spawner硬币脚本无法正常工作,并且没有出现任何错误。我该怎么做才能让我的硬币不出现在游戏的其他对象上,而只是出现在地面上?这是我的脚本:

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

public class Object_Spawner : MonoBehaviour
{
    public GameObject player;
    public GameObject[] coins;
    public GameObject[] groun22;       
    private float coinSpawnTimer = 1.0f;

    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);
    }
}

0 个答案:

没有答案