Version: 2022.3
LanguageEnglish
  • C#

Plane.SetNormalAndPosition

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public void SetNormalAndPosition(Vector3 inNormal, Vector3 inPoint);

Parameters

inNormal The plane's normal vector.
inPoint A point that lies on the plane.

Description

Sets a plane using a point that lies within it along with a normal to orient it.

Note that the normal must be a normalised vector.

using UnityEngine;

public class Example : MonoBehaviour { public float fieldLength; public float fieldWidth; public Plane goalLine1; public Plane goalLine2; public Plane leftSideLine; public Plane rightSideLine;

void Start() { // Set up goal lines of a playing field. goalLine1.SetNormalAndPosition(Vector3.forward, Vector3.forward * fieldLength / 2); goalLine1.SetNormalAndPosition(-Vector3.forward, -Vector3.forward * fieldLength / 2);

// Set up side lines. leftSideLine.SetNormalAndPosition(-Vector3.right, -Vector3.right * fieldWidth / 2); rightSideLine.SetNormalAndPosition(Vector3.right, Vector3.right * fieldWidth / 2); } }

Additional resources: Set3Points.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961