正确播放粒子系统组件? [英] Properly play Particule System component?

查看:82
本文介绍了正确播放粒子系统组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何正确播放GameObject附带的粒子系统组件?我还将以下脚本附加到了我的GameObject上,但粒子系统无法播放.我该如何解决?

How can I properly play the particle system component, which is attached to a GameObject? I also attached the following script to my GameObject but the Particle System does not play. How do I fix this?

public Transform gameobject1;
public Transform gameobject2;
public ParticleSystem particules;

void Start()
{
    float distance = Vector3.Distance(gameobject1.position, gameobject2.position);
}

void Update()
{
    if(distance == 20)
  {
      particules.Play();
  }
}

推荐答案

我看不到您在课堂上宣布距离,但是您在更新时使用了它.与其他成员一起将距离声明为私人漂浮物,并在开始时对其进行定义.

I don't see you declaring distance in your class, but you use it under update. Declare distance as a private float with your other members and just define it in start.

假设您的代码不完全是这样,那么您的问题也似乎源于使用带距离的实心值.尝试使用小于或等于20的值.

Assuming that your code isn't exactly like that, your also issue looks like it stems from using a solid value with distance. Try using less than or equal to 20.

if(distance <= 20)

或者您可以尝试大于19小于21.

Or you could try greater than 19 and less than 21.

if(distance <= 21 && distance >= 19)

这篇关于正确播放粒子系统组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆