无论发射器速度如何,粒子流的长度都应相同

发布于 2024-08-19 20:37:42 字数 671 浏览 3 评论 0原文

我正在为我们的学生游戏编写一个粒子系统,但遇到了一些障碍。我想改善舰船火箭的效果,但我似乎不知道如何做。

以下是效果在静止船只上的外观:

alt text

以下是效果在移动船只上的外观:

alt text

我希望火焰始终保持相同的长度。这是 ParticleTick 函数:

void Particle::Tick(float a_DT)
{
    // temporarily turned off to see the effect of the rest of the code more clearly
//m_Pos += m_Vel;

    if (m_Owner) { m_Pos += m_Owner->GetParentSpeed(); }

    m_Life -= 1;

    if (m_Life <= 0) { m_Alive = false; }
}

提前致谢。

编辑:为了澄清一点,我希望效果拖尾,但我希望它以相同的方式拖尾,无论发射器的速度如何。

I'm writing a particle system for our student game, and I've run into a bit of a snag. I want to improve the effect on the ships' rockets, but I can't seem to figure out how.

Here's how the effect looks on a stationary ship:

alt text

And here's how it looks on a moving ship:

alt text

I want the flames to be the same length consistently. Here's Particle's Tick function:

void Particle::Tick(float a_DT)
{
    // temporarily turned off to see the effect of the rest of the code more clearly
//m_Pos += m_Vel;

    if (m_Owner) { m_Pos += m_Owner->GetParentSpeed(); }

    m_Life -= 1;

    if (m_Life <= 0) { m_Alive = false; }
}

Thanks in advance.

EDIT: To clear things up a bit, I want the effect to trail, but I want it to trail the same way regardless of the emitter's speed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

淡水深流 2024-08-26 20:37:42

您根据母舰的速度使粒子移动得更快或更慢,但它们的寿命是某个常数,您可以将其递减一直到达到零,对吗?

您可能想要做的是将生命周期设置为距离值,而不是某个刻度数。然后,从生命周期中减去船舶的速度(或者在每个刻度上添加到每个粒子的任何速度)。当寿命变为负数时,杀死粒子。


我认为这就是你想要的......但如果你对算法进行两处更改,它可能会更酷(也更现实):

  1. 当前行为(尾部的长度)是正确的如果粒子
    发动机的速度取决于推力(加速度
    而不仅仅是速度)。

  2. 一旦粒子离开引擎,其速度/方向的任何变化
    船对其没有影响。一旦粒子发射出去,它的速度
    和方向是恒定的,直到消失。这实际上应该
    当你转动船或发生巨大变化时看起来很酷
    加速度。

干杯。

You're making the particles move faster or slower according to the parent ship's speed, but their lifetime is some constant that you decrement by one until you reach zero, correct?

What you probably want to do is set the lifetime to a distance value, rather than some number of ticks. Then, subtract the ship's speed (or whatever you're adding to each particle on each tick) from the lifetime. When lifetime goes negative, kill the particle.


I think that's what you want... but it might be cooler (and more realistic) if you make two changes to your algorithm:

  1. The current behavior (length of the tail) is correct if the particle
    speed coming out of your engines is based upon thrust (acceleration
    rather than just speed).

  2. Once a particle leaves the engine, any changes in speed/direction of
    the ship have no effect on it. Once the particle is emitted, it's speed
    and direction are constant until it fizzles out. This should actually
    look pretty cool when you're turning the ship, or dramatically changing
    acceleration.

Cheers.

欲拥i 2024-08-26 20:37:42

如果您希望它具有一致的长度,那么您需要通过将其除以父级的速度来标准化父级的速度。显然,如果父级坐着不动,那么这将不起作用,因此在这种情况下,您需要粒子处于某种“空闲”状态(随机圆锥分布或诸如此类的东西)。

另外,仅在构造函数中获取速度,并在滴答期间继续使用它。

If you want it to have its own length consistently then you'll need to normalize the parent's velocity by dividing it by the parent's speed. Obviously this will not work if the parent is sitting still so you'll need some sort of "idle" state for the particles in that case (random conical distribution or whatnot).

Also, only acquire the velocity in the constructor, and keep using it during the ticks.

Smile简单爱 2024-08-26 20:37:42

系统中是否存在随机变量?每个发射器的粒子数量、粒子寿命等?这将导致路径长度不同。

Are there any random variables in the system? Number of particles per emitter, particle life etc? This would cause the trails to be of varying length.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文