Hello, i have the below code:
using UnityEngine;
using System.Collections;
public class PlayerStatus : MonoBehaviour {
public int Lives = 5;
// public ParticleEmitter EnemyXplode;
//
// public void OnGUI(){
// GUI.Label(new Rect(10, 10, 100, 30), System.String.Format(“LIVES: {0}”, Lives));
// }
//
// public void OnTriggerEnter(Collider collider) {
// Lives–;
// Vector3 enemy_pos = collider.transform.position;
// Destroy(collider.gameObject);
// ParticleEmitter xplode = (ParticleEmitter)Instantiate(EnemyXplode, enemy_pos, Quaternion.identity);
// //ParticleEmitter xplode = (ParticleEmitter)Instantiate(EnemyXplode, enemy_pos, Quaternion.identity);
// xplode.Emit();
// }
public GameObject Thing;
public void OnGUI() {
GUI.Label(new Rect(20, 20, 100, 20), System.String.Format(“LIVES: {0}”, Lives));
}
public void OnTriggerEnter(Collider collider) {
Lives–;
Vector3 enemy_position = collider.transform.position;
Destroy(collider.gameObject);
ParticleEmitter explosion = (ParticleEmitter)Instantiate(Thing, enemy_position, Quaternion.identity);
explosion.Emit();
}
}
I can only drag and drop the particle emitter prefab into the player object if i invoke the public GameObject Variable; however the how-to guide i was reading told me to use public ParticleEmitter Variable; If i use the ParticleEmitter variable type, it will not let me drag and drop the particle effect, however if i use the GameObject it will, but the script won’t work, i can an error about “can’t cast from source”. Any ideas?