Version: 2021.2
public Vector3 normal ;

描述

接触点的法线。

以下示例将绘制一条线来表示碰撞中的每条法线。将在 Scene 视图中绘制每条直线。

using UnityEngine;

public class Example : MonoBehaviour { void OnCollisionEnter(Collision other) { // Print how many points are colliding with this transform Debug.Log("Points colliding: " + other.contacts.Length);

// Print the normal of the first point in the collision. Debug.Log("Normal of the first point: " + other.contacts[0].normal);

// Draw a different colored ray for every normal in the collision foreach (var item in other.contacts) { Debug.DrawRay(item.point, item.normal * 100, Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f), 10f); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961