RaycastHit
射线
[NativeHeader("PhysicsScriptingClasses.h")]
[NativeHeader("Runtime/Interfaces/IRaycast.h")]
[NativeHeader("Runtime/Dynamics/RaycastHit.h")]
[UsedByNativeCode]
public struct RaycastHit
{
public Collider collider { get; }
public Vector3 point { get; set; }
public Vector3 normal { get; set; }
public Vector3 barycentricCoordinate { get; set; }
public float distance { get; set; }
public int triangleIndex { get; }
public Vector2 textureCoord { get; }
public Vector2 textureCoord2 { get; }
[Obsolete("Use textureCoord2 instead. (UnityUpgradable) -> textureCoord2")]
public Vector2 textureCoord1 { get; }
public Transform transform { get; }
public Rigidbody rigidbody { get; }
public Vector2 lightmapCoord { get; }
}
hit.normal:The normal of the surface the ray hit. 物品掉落到头上弹开:
RaycastHit hit; string temp;
void JudgePoint()
{
Vector3 downss = MediaCtrl.OBJS["SM_NvHai_PZ"].transform.position -transform.position;
if (Physics.Raycast(transform.position, downss, out hit, 1000f))
{
temp = Vector3.Dot(hit.normal, Vector3.forward) > 0 ? temp = "左" : temp = "右";
}
}
左右滑动,躲避高空坠物
|