using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletDestroy : MonoBehaviour
{
void Update()
{
Destroy(gameObject, 10f);
}
private void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "Zombie")
{
other.gameObject.GetComponent<Zombie>().zHP -= 100;
Destroy(gameObject);
}
if (other.gameObject.tag == "Player")
{
Destroy(gameObject);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletDestroy : MonoBehaviour
{
void Update()
{
Destroy(gameObject, 10f);
}
private void OnCollisionEnter(Collision other)
{
if (other.gameObject.TryGetComponent(out Zombie zombie));
{
zombie.zHP -= 100;
Destroy(gameObject);
}
if (other.gameObject.tag == "Player")
{
Destroy(gameObject);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletDestroy : MonoBehaviour
{
void Update()
{
Destroy(gameObject, 10f);
}
private void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "Zombie")
{
TryGetComponent(out Zombie zombie);
zombie.zHP -= 35;
Destroy(gameObject);
}
if (other.gameObject.tag == "Player")
{
Destroy(gameObject);
}
}
}