Unity Raycast Collision Detection || Unity 3D Tutorial
Hi In this Unity tutorial, I will show you how to Detect Collision from using Raycast in Unity 3D I write a C# script that you can attach to your game object to have the Click Feature. Here is the script you can use in your games. using System.Collections; using System.Collections.Generic; using UnityEngine; public class RaycastDetect : MonoBehaviour { public LayerMask layerMask; void Update() { RaycastHit hit; if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity, layerMask)) { Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow); Debug.Log("Hit"); } else { Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 1000, Color.white); Debug.Log("Not Hit"); } } } ▼ SUBSCRIBE OUR CHANNEL▼ https://www.youtube.com/channel/UCWyK... Please Like Share Subscribe Thank You So Much.
Download
0 formatsNo download links available.