32 lines
707 B
C#
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()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|