Files
VR_Game/Assets/Scripts/Bullet.cs
manhduyhoang90 4fc787e83f .
2026-05-09 09:00:14 +07:00

45 lines
915 B
C#

using UnityEngine;
public class Bullet : MonoBehaviour
{
public float speed = 10f;
void Update()
{
transform.position += transform.forward * speed * Time.deltaTime;
}
private void OnTriggerEnter(Collider other)
{
// Trúng khiên
if (other.CompareTag("Shield"))
{
Destroy(gameObject);
return;
}
// Trúng đầu
if (other.CompareTag("BluePlayer"))
{
HitBox hit = other.GetComponent<HitBox>();
if (hit != null)
{
hit.blueplayer.Die();
}
Destroy(gameObject);
}
if (other.CompareTag("RedPlayer"))
{
HitBox hit = other.GetComponent<HitBox>();
if (hit != null)
{
hit.redplayer.Die();
}
Destroy(gameObject);
}
}
}