Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使一个产卵平台在屏幕上向下移动以与驱逐舰碰撞?_C#_Unity3d - Fatal编程技术网

C# 如何使一个产卵平台在屏幕上向下移动以与驱逐舰碰撞?

C# 如何使一个产卵平台在屏幕上向下移动以与驱逐舰碰撞?,c#,unity3d,C#,Unity3d,我试着制作一个3D游戏,比如《冰塔》,在我的代码中,生成具有随机位置和随机比例的平台效果很好,但我想让生成的平台下移到屏幕外,与驱逐舰发生碰撞,然后消失。我该怎么做 守则: using System.Collections; using System.Collections.Generic; using UnityEngine; public class LevelGenerate : MonoBehaviour { public GameObject platformPrefabs;

我试着制作一个3D游戏,比如《冰塔》,在我的代码中,生成具有随机位置和随机比例的平台效果很好,但我想让生成的平台下移到屏幕外,与驱逐舰发生碰撞,然后消失。我该怎么做

守则:

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

public class LevelGenerate : MonoBehaviour
{
    public GameObject platformPrefabs;

    public int numberOfPlatform = 200;
    public float levelWidth = 4f;
    //public int minY = 3;
    public int maxY = 9;

    public float minScale = 2.5f;
    public float maxScale = 9f;



    // Start is called before the first frame update
    void Start()
    {


        Vector3 spawnPosition = new Vector3();

        for (int i = 0; i < numberOfPlatform; i++)
        {
            spawnPosition.y += maxY;
            spawnPosition.x = Random.Range(-levelWidth, levelWidth);

            GameObject go = Instantiate(platformPrefabs, spawnPosition, Quaternion.identity);

            Vector3 randomSize = new Vector3(Random.Range(minScale, maxScale), 0.25f, 1);

            go.transform.localScale = randomSize;

        }

    }
}
使用系统集合;
使用System.Collections.Generic;
使用UnityEngine;
公共类LevelGenerate:单行为
{
公共游戏对象平台预制;
公共int numberOfPlatform=200;
公共浮动水平宽度=4f;
//公共整数minY=3;
公共整数maxY=9;
公共浮标最小刻度=2.5f;
公共浮点数最大刻度=9f;
//在第一帧更新之前调用Start
void Start()
{
Vector3 spawnPosition=新Vector3();
for(int i=0;i