hi i’am making an fps game i’ave got everything sorted but the damage script, i’ave tried the standard packages one but that isn’t working. i’ave got the code here
flood is the enemy btw
function Start (){
if (Collision.GameObject.name == “Flood”){
Destroy(GameObject.Find(“Flood”));
}
}
Your function is called start. This means that as soon as the script starts, it checks if the bullet and the other object are colliding, but then it doesn’t ever check again. Change function Start to be function Update. This should solve your problem.
Is this script attached to the enemy? Is so try something like this and let me know what happens:
function OnCollisionEnter(object : Collision) {
if(object.collider.name == "Bullet"){
Destroy(object);
Destroy(gameObject);
}
}
I haven’t tested this, but give it ago.
---- Update ----
I’m assuming your player fires bullets already.
On your bullet, make sure it has a tag called “Bullet” as well as a collider, also make sure your flood (enemy) also has a collider.
In the script attached of your enemy, you want something like this:
function OnCollisionEnter(object : Collision){
if(object.gameObject.tag == "Bullet"){
print("Bullet has hit us (enemy)");
Destroy(gameObject);
}
}