Files
WildRoot/Assets/Script/Bullet.cs
T

52 lines
1.1 KiB
C#
Raw Normal View History

2026-04-14 17:06:58 +09:00
using UnityEngine;
public class Bullet : MonoBehaviour
{
public float speed = 8f;
private Rigidbody rb;
public GameObject effect;
2026-04-15 12:59:37 +09:00
public AudioSource audioSource;
2026-04-14 17:06:58 +09:00
public AudioClip clip;
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Shield"))
{
return;
}
if (other.CompareTag("Player"))
{
Instantiate(effect, other.transform.position, Quaternion.identity);
PlayerController pc = other.GetComponent<PlayerController>();
if (pc != null)
{
pc.Die();
2026-04-15 12:59:37 +09:00
GameObject.Find("The_Lead_Hits_Deep").GetComponent<AudioSource>().Stop();
2026-04-14 17:06:58 +09:00
}
}
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
rb = GetComponent<Rigidbody>();
rb.linearVelocity = transform.forward * speed;
Destroy(gameObject, 3f);
}
// Update is called once per frame
void Update()
{
}
}