using UnityEngine;
public class FootstepsS : MonoBehaviour
{
public ParticleSystem system;
public float delta = 1;
public float gap = 0.5f;
public bool ShowFootsteps = true;
private Vector3 lastEmit;
private int dir = 1;
private void Start()
{
lastEmit = transform.position;
}
private void Update()
{
if (!ShowFootsteps)
{
return;
}
if (Vector3.Distance(lastEmit, transform.position) > delta)
{
var pos = transform.position + (transform.right * gap * dir);
dir *= -1;
ParticleSystem.EmitParams ep = new ParticleSystem.EmitParams();
ep.position = pos;
ep.rotation = transform.rotation.eulerAngles.y;
system.Emit(ep, 1);
lastEmit = transform.position;
}
}
}
Unity 3D 脚印 足迹 粒子特效实现
最新推荐文章于 2024-09-16 08:07:29 发布