physic raycaster limit unity code example
Example 1: rotatearound unity
using UnityEngine;
public class Example : MonoBehaviour
{
private Vector3 target = new Vector3(5.0f, 0.0f, 0.0f); void Update()
{
transform.RotateAround(target, Vector3.up, 30 * Time.deltaTime);
}
}
Example 2: raycasting in unity
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("Did Hit");
}