- if(hit.transform.tag == "Item") 를 적용시키려면 사라짐을 적용할 오브젝트 테그에 "Item"테그를 설정해주어야 한다.
using UnityEngine;
using System.Collections;
public class ShootRay : MonoBehaviour {
public float rayDistance = 100f;
// Update is called once per frame
void Update () {
if(Input.GetMouseButton(0)) {// 0은 왼쪽버튼, 스마트폰에서 터치.
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); //카메라에서 레이를 쏜다.
RaycastHit hit;
if (Physics.Raycast(ray, out hit, rayDistance))
{
if(hit.transform.tag == "Item") ///
Destroy(hit.transform.gameObject);
}
}
}
}
'Unity' 카테고리의 다른 글
유니티 2D 스프라이트 (0) | 2014.08.07 |
---|---|
Animator 애니메이터 (매카님) 에서 지원하는 파라미터 (0) | 2014.08.07 |
유니티 물체 배치 (0) | 2014.08.06 |
Trail Renderer (0) | 2014.08.06 |
Trail Renderer (0) | 2014.08.06 |