[Game] Dodge
1. 총알피하기 게임 제작 2. 시간별로 단계 설정 3. 시작화면 및 이펙트, 사운드 삽입
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Bullet : MonoBehaviour
|
||||
{
|
||||
public float speed = 8f;
|
||||
private Rigidbody rb;
|
||||
|
||||
public GameObject effect;
|
||||
|
||||
public AudioSource audio;
|
||||
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();
|
||||
GameObject.Find("Music").GetComponent<AudioSource>().Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user