1.螺旋线参数方程
x = (α + βt) cos(t); y = (α + βt) sin(t);
2.使用LineRenderer绘制
using UnityEngine;
public class Draw : MonoBehaviour
{
public float addSpeed = 3f;
public float alpha = 1f;
public float beta = 1f;
private float t = 0f;
private float r = 0f;
private int pointCounter = 0;
public LineRenderer lineRenderer;
void Update()
{
t += addSpeed * Time.deltaTime;
r = (alpha + beta * t);
Vector2 curPoint = new Vector2(r * Mathf.Cos(t), r * Mathf.Sin(t));
lineRenderer.positionCount++;
lineRenderer.SetPosition(pointCounter, curPoint);
pointCounter++;
}
}
3.效果
|