粒子系统统一并不总是显示,统一
因此,我正在尝试为我的一个小太空游戏添加粒子效果,我得到轴“垂直”,然后检查粒子系统是否大于0(向前)
flyfloat = Input.GetAxis("Vertical");
if(flyfloat > 0)
{
particles.Play();
}
else
{
particles.Stop();
}
控制它是否在播放粒子系统,但我遇到的问题是,它只会给出一些粒子,然后停止,我已经查看了flyfloat
,它在1。
问题可能是什么?
谢谢
So I'm trying to add a particle effect to a little space game of mine, I get axis "Vertical", then check if it is greater than 0 the particle system plays (going forward)
flyfloat = Input.GetAxis("Vertical");
if(flyfloat > 0)
{
particles.Play();
}
else
{
particles.Stop();
}
That controls whether it is playing the particle system, but the issue i have is that it only gives some particles and then stops, I've viewed the flyfloat
and it is at 1.
What may the problem be here?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题是不完整的,例如,我不知道您在哪里使用这些代码行。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
假设您是在
update()
方法中调用它。让我首先说明这里发生了什么。因此,当您按update()
时,请在按下 up_arrow 键flyfloat = 1
时,将调用每个帧。没关系,但是现在,当您进入IF循环时,检查flyfloat> 0
和调用partciles.play()
它被称为每个update> update()
循环表示每个帧>正在播放每个帧,因此根本不玩。同样,每当您停止按下 up_arrow 键时,flyfloat = 0
它在其他循环内部并停止播放preshitlesystem
。因此,为了解决此问题,您可以引入一个布尔值,该布尔值
partciles.play()
andpartciles.stop()
在按下按下 up_arrow 键。下面的代码将使
pracelesystem
在按 up_arrow 键时播放,并在按下 down_arrow 键时将其停止。You question is incomplete as for example I don't know where you are using these lines of code.. inside an
Update()
method or aStart()
method.Assuming you are calling it in
Update()
method. Let me explain first what is happening wrong here. So asUpdate()
gets called each frame when you pressing UP_Arrow keyflyfloat = 1
. that's ok but now as you go inside the if loop to checkflyfloat > 0
and callspartciles.Play()
it is being called everyUpdate()
loop means every frame so what's happening is yourParticleSystem
is getting played every frame so not playing at all. Also whenever you stops pressing the UP_Arrow key theflyfloat = 0
for which it's going inside the else loop and stops playing theParticleSystem
.So to solve this you can introduce a Boolean which makes
partciles.Play()
andpartciles.Stop()
gets called once when you are pressing UP_Arrow key.below code will make the
ParticleSystem
play when you press UP_Arrow key and stops it when you press DOWN_Arrow key