g1/Assets/Bullet.cs
2026-01-26 20:59:13 +09:00

32 lines
707 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : MonoBehaviour
{
public float speed = 8f;
private Rigidbody bulletRigidbody;
void Start()
{
bulletRigidbody = GetComponent<Rigidbody>();
bulletRigidbody.linearVelocity = transform.forward * speed;
Destroy(gameObject, 3f);
}
void OnTriggerEnter(Collider other)
{
if(other.tag == "Player")
{
PlayerController playerController = other.GetComponent<PlayerController>();
if(playerController != null )
{
playerController.Die();
}
}
}
void Update()
{
}
}