-1
我正在創建一個網格物體,但不知道如何添加一個碰撞體: 對於GameObject,很容易添加,但不知道如何將其添加到網格。我如何添加一個對撞機到網格?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Mesh : MonoBehaviour
{
public int resX = 2; // 2 minimum
public int resZ = 2;
public float length = 1f;
public float width = 1f;
private MeshFilter meshf;
private UnityEngine.Mesh mesh;
private Vector3[] vertices;
private int v1;
private int v2;
private void Start()
{
GenerateMesh();
}
private void GenerateMesh()
{
meshf = GetComponent<MeshFilter>();
mesh = new UnityEngine.Mesh();
meshf.mesh = mesh;
mesh.Clear();
}
}
您不能對撞機添加到網格。你有一個碰撞對象與一個網格附加到它 – Hellium