Unity | ParticleSystem 粒子效果的跟随触发

粒子效果无法直接修改position属性进行修改

(错误的方法:
particleSystem.shape.postion = other.transform.postion

需要获取shape模块进行修改
ParticleSystem.ShapeModule _editableShape = m_particleSystem.shape;

public class ParticleSystemShapeChanger: MonoBehaviour
 {
     private ParticleSystem m_particleSystem;
 
     private void Start()
     {
         m_particleSystem = GetComponent();
         ParticleSystem.ShapeModule _editableShape = m_particleSystem.shape;
         _editableShape.position = new Vector3(1f, 2f, 3f);
     }
 }

Unity | ParticleSystem 粒子效果的跟随触发_第1张图片

eg.

先将脚本挂载到对应对象上
并把对应的粒子系统效果挂载到脚本上

public class ParticleDemo: MonoBehaviour
{
	public ParticleSystem m_particleSystem;
 
    private void FixedUpdate()
    {
        ParticleSystem.ShapeModule _editableShape = m_particleSystem.shape;
		_editableShape.position = transform.position;
    }
}

可以用来做一些追踪的效果
Unity | ParticleSystem 粒子效果的跟随触发_第2张图片

你可能感兴趣的:(Unity,unity)