粒子系统未初始化
Particle System not Initializing
我正试图在我的预制对象被销毁之前实例化一个粒子系统,但我无法找出什么不起作用。我检查了唤醒时播放。
[SerializeField] ParticleSystem destruction;
if (destruction != null)
{
Debug.Log("this objects transform: " + this.transform);
Instantiate(destruction, this.transform);
}
if (tag != "Wall")
{
Destroy(gameObject);
}
正在使用
Instantiate(destruction, this.transform.position, this.transform.rotation);
成功了。
Unity中Instantiate的用法,这是一个简单的例子
//pass in d preset
public GameObject explosion; // Explosion effect Prefab component (an explosion animation)
void OnExplode()
{
// Create a Quaternion with a random rotation angle
// Quaternion.Euler Euler angles
// Returns a rotation angle that rotates y degrees around the y axis, x degrees around the x axis, and z degrees around the z axis.
Quaternion randomRotation = Quaternion.Euler(0f, 0f, Random.Range(0f, 360f));
// Initialize the instance of explosion
// Parameter 1: is the preset Parameter 2: The coordinates of the instantiated preset Parameter 3: The rotation angle of the instantiated preset
Instantiate(explosion, transform.position, randomRotation);
}
谢谢 希望对你有帮助
我正试图在我的预制对象被销毁之前实例化一个粒子系统,但我无法找出什么不起作用。我检查了唤醒时播放。
[SerializeField] ParticleSystem destruction;
if (destruction != null)
{
Debug.Log("this objects transform: " + this.transform);
Instantiate(destruction, this.transform);
}
if (tag != "Wall")
{
Destroy(gameObject);
}
正在使用
Instantiate(destruction, this.transform.position, this.transform.rotation);
成功了。
Unity中Instantiate的用法,这是一个简单的例子
//pass in d preset
public GameObject explosion; // Explosion effect Prefab component (an explosion animation)
void OnExplode()
{
// Create a Quaternion with a random rotation angle
// Quaternion.Euler Euler angles
// Returns a rotation angle that rotates y degrees around the y axis, x degrees around the x axis, and z degrees around the z axis.
Quaternion randomRotation = Quaternion.Euler(0f, 0f, Random.Range(0f, 360f));
// Initialize the instance of explosion
// Parameter 1: is the preset Parameter 2: The coordinates of the instantiated preset Parameter 3: The rotation angle of the instantiated preset
Instantiate(explosion, transform.position, randomRotation);
}
谢谢 希望对你有帮助