728x90
OnMouseDown
콜라이더 또는 GUI 요소에 대한 마우스 클릭을 감지하는 방법을 알아봅니다.
MouseClick
using UnityEngine;
using System.Collections;
public class MouseClick : MonoBehaviour
{
private Rigidbody rb;
private void Awake()
{
rb = GetComponent<Rigidbody>();
}
void OnMouseDown ()
{
rb.AddForce(-transform.forward * 500f);
rb.useGravity = true;
}
}
출처 : 유니티 튜토리얼
728x90
'게임엔진 > Unity' 카테고리의 다른 글
Unity - 데이터 유형 (0) | 2024.07.02 |
---|---|
Unity - GetComponent (0) | 2024.07.02 |
Unity - GetAxis (0) | 2024.07.02 |
Unity - 선형 보간 (0) | 2024.07.02 |
Unity - Coroutine (0) | 2024.07.01 |