- Home /
delete a cube with particles
can someone please make it so that this script also deletes the object it is attached to or just delete the object it is attached to. you will be helping me a lot with it. thank you in advance.
using UnityEngine;
public class Flamable : MonoBehaviour {
public float FireHealth = 50;
public float MaxFireHealth = 50;
public float HealthRegen = 5;
public bool IsOnFire = true;
void OnParticleCollision(GameObject other) {
if(IsOnFire) {
FireHealth -= 1.0f;
if (FireHealth <= 0) {
IsOnFire = false;
transform.GetComponent<ParticleEmitter>().emit = false;
// other things to do when fire goes out
}
}
}
void Update() {
if (IsOnFire) {
FireHealth += Time.deltaTime * HealthRegen;
if (FireHealth > MaxFireHealth) {
FireHealth = MaxFireHealth;
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
I need help !!! -3 Answers
change to glow texture on mouse click 0 Answers
Trying to fire a Projectile 2 Answers