Hello,
I’m new learning Java, Basically with little help with using “Scripting API” part of unity & YouTube, I have got this so far;
(Health of object script below)
// This section is health for object.
var health :int = 8;
function Damage(damage:int){
health -= damage;
if(health <= 0)Destroy(gameObject);
}
// This section is effect when object is destoryed.
var explosion: GameObject;
//var clip : AudioClip;
function OnCollisionEnter(){
var expl = Instantiate(explosion, transform.position, Quaternion.identity);
Destroy(gameObject);
Destroy(expl, 5); // delete the object after 5 seconds.
}
// Not working on Audio atm
// reload : AudioClip;
//function Start() {
// AudioSource.PlayClipAtPoint(clip, new Vector3 (5, 1, 2));
//}
I also have “Bullet” which basically when “player hits item, Item loses health” (Depending what i’ve put health to) but what i need help with is;
Particle system works fine does that it should do (But i want to use a prefab i’ve made instead of Particles this is where it stops working. When player hits object once it auto destroys and replaces it with the prefab. Is there a way to make it same as what the Particle system does just using objects instead?
Thank you for your time & help
Luke