(unity)有没有办法设置粒子系统中每个粒子的位置?

(unity)Is there a way to set the position of every particle in a particle system?

所以我想在玩家周围制作一个光环,就像在魔兽争霸 3 或流放之路等中一样,使用粒子系统,当角色空闲时它工作得很好。事情是在它不空闲的时候。

我试过使用 Update() 更改粒子系统本身的位置,但这并没有真正影响粒子的位置。我需要的是将它们中的每一个设置为玩家位置。

有没有办法将粒子设置到玩家的位置?(或任何位置)

谢谢

回答你的问题

您可以更改 ParticleSystem.simulationSpace

Controls whether particles are animated in the parent object’s local space (therefore moving with the parent object), in the world space, or relative to a custom object (moving with a custom object of your choosing).

ParticleSystemSimulationSpace.Local

Simulate particles in local space

通过 Main Module

的 Inspector

或通过类似

的代码
GetComponent<ParticleSystem>().main.simulationSpace = ParticleSystemSimulationSpace.Local;

回答你的问题标题

是的。您可以通过 ParticleSystem.GetParticles, change their ParticleSystem.Particle.position and then write them back into the system using ParticleSystem.SetParticles

获取粒子
var particles = new ParticleSystem.Particle[theParticleSystem.main.maxParticles];
var currentAmount = theParticleSystem.GetParticles(particles)

// Change only the particles that are alive
for (int i = 0; i < currentAmount; i++)
{
    particles[i].position = XYZ;
}

// Apply the particle changes to the Particle System
theParticleSystem.SetParticles(particles, currentAmount);