【发布时间】:2015-02-07 10:04:18
【问题描述】:
我对编程非常陌生,并且使用 unity xD 非常新我正在尝试自己制作一个小游戏(2D)。我需要一些帮助来配置粒子系统。
using UnityEngine;
using System.Collections;
public class CharacterController : MonoBehaviour {
public float charForce = 75.0f;
public float fwMvSp = 3.0f;
void FixedUpdate ()
{
bool engineActive = Input.GetButton("Fire1");
if (engineActive)
{
rigidbody2D.AddForce(new Vector2(0, charForce));
}
Vector2 newVelocity = rigidbody2D.velocity;
newVelocity.x = fwMvSp;
rigidbody2D.velocity = newVelocity;
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
问题是如果未按下按钮,我不知道如何实现停止粒子发射的代码。我尝试了一个 if 语句,但我收到一个错误,告诉我检查粒子系统是否附加到游戏对象。提前感谢您的帮助:)
【问题讨论】:
标签: c# unity3d particle-system particles