using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Beisaier : MonoBehaviour {
public Transform spere1;
public Transform spere2;
public Transform spere3;
public Transform spere4;
Vector3[] arr = new Vector3[100];
Vector3 v3 = new Vector3();
float indexT = 0;
int index = 0;
LineRenderer lines = new LineRenderer();
void Start () {
wire();
}
void Update () {
lins();
}
void wire()
{
GameObject obj = new GameObject("LineRenderer");
lines = obj.AddComponent<LineRenderer>();
lines.positionCount = 100;
lines.positionCount = 100;
lines.material.color = Color.red;
Color c = new Color();
lines.SetWidth(0.1f, 0.1f);
}
void lins()
{
if(indexT>=0&&indexT <1&&index <100)
{
v3 = spere1.position * ((1 - indexT) * (1 - indexT) * (1 - indexT)) + 3 * spere2.position * indexT * ((1 - indexT)*(1-indexT)) + 3*spere4.position * indexT * indexT *(1-indexT)+spere3.position* indexT*indexT *indexT;
arr[index] = v3;
index++;
indexT += 0.01f;
}
else
{
index = 0;
indexT = 0;
}
lines.SetPositions(arr);
}
}
用贝塞尔制作曲线
最新推荐文章于 2023-12-03 02:45:00 发布