using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class raycast_hand : MonoBehaviour {
public Transform target_wall;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
RaycastHit hit;
Debug.DrawRay(transform.position, transform.forward * 2.0f, Color.red);
if(Physics.Raycast(transform.position, transform.forward, out hit, 2.0f))
{
target_wall = hit.transform;
Vector3 incomingVec = hit.point - transform.position;
//hit.point: the impact point in world space where the ray hit the collider.
Debug.DrawLine(transform.position, hit.point, Color.red); //ray
//hit.normal: the normal of the surface the ray hit.
Debug.DrawRay(hit.point, hit.normal, Color.green); //wall surface normal
//hit.distance //The distance from the ray's origin to the impact point.
Debug.DrawRay (transform.position, transform.forward * hit.distance, Color.blue);
}
}
}
'XR > Unity3D' 카테고리의 다른 글
Unity 3D에서 object 색상 지정하기 (0) | 2020.11.08 |
---|---|
유니티에서 벡터 사잇각 찾기 (0) | 2019.03.20 |
유니티 - 레이캐스팅 이용하기 (0) | 2018.10.14 |
Unity - 여러개의 태그로 가장 가까운 물체 찾기 (0) | 2018.09.30 |
Unity + Oculus Rift (0) | 2018.08.16 |
댓글