주변에 BOX 만들고 충돌반응 시키기
- 박스들 만들어서 배치하기
- 블럭이 떨어질 수 있도록 RigidBody 세팅하기
- 떨어지는 아래 부분에 블럭체크 할 수 있는 영역 만들기
- 영역 통과할 때 뭐가 떨어지는지 체크하기
- 박스 숫자 카운트 해서 16개 이상이면 게임 종료 시키기
using UnityEngine;
using System.Collections;
public class Shot : MonoBehaviour {
public float Power = 200f;
public float Range = 100;
void Update()
{
Debug.DrawRay (transform.position, this.transform.forward * Range, Color.red);
if (Input.GetKeyDown (KeyCode.Space)) {
RaycastHit hit ;
if(Physics.Raycast(transform.position, transform.forward, out hit, Range))
{
if(hit.collider.gameObject.tag == "Box")
{
Debug.Log(hit.collider.name);
hit.rigidbody.AddForceAtPosition(transform.forward * Power, hit.point);
}
}
}
}
}