Unity 射线反射

using UnityEngine;/// /// descript:射线反射/// author: wushengnuo/// public clas
using UnityEngine;/// 
/// descript:射线反射
/// author: wushengnuo
/// 
public class RayReflect : MonoBehaviour
{public Transform p1;public Transform p2;private void Update(){RaycastHit hit;Vector3 direction = p2.position - p1.position;direction.Normalize();if (Physics.Raycast(p1.position, direction, out hit)){rayPoint = hit.point;Vector3 reflect= Vector3.Reflect(direction, hit.normal);reflectRayEnd = reflect * 100+hit.point;}}Vector3 rayPoint;Vector3 reflectRayEnd;public void OnDrawGizmos(){Gizmos.color = Color.red;Gizmos.DrawLine(p1.position, rayPoint);Gizmos.DrawLine(rayPoint, reflectRayEnd);}}