unity 物体运动轨迹绘制
① create empty,命名为LineRender
② 在Assects中新建材质,选择Shader为Sprites/Default,并设置轨迹颜色,如下图:
③ 选择①中创建的object,添加Line Render属性,然后将②中新建的材质赋给该object,如下图:
展开Line Render,拖动Width可设置轨迹宽度
④ 创建c#脚本,拖至运动物体上,代码如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class draw_orbit : MonoBehaviour
{
// 绘制轨迹组件
public LineRenderer line;
public List<Vector3> points;
// 读取本地txt文件位置信息,改变物体位置
string[] text_buf;
int i = 0;
// Start is called before the first frame update
void Start(