版本:Unity 6(6000.0)
语言中文(简体)
  • C#

Plane.GetSide

提交建议

成功!

感谢您帮助我们提升 Unity 文档的质量。尽管我们无法接受所有提交,但我们会阅读用户提交的每一项建议并酌情进行更新。

关闭

提交失败

您的建议无法提交,原因不明。请在几分钟后<a>重试</a>。感谢您花时间帮助我们提升 Unity 文档的质量。

关闭

取消

声明

public bool GetSide(Vector3 point);

说明

一个点是否在平面的正方向?

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Plane goalLine1; public Plane goalLine2; public Plane leftSideLine; public Plane rightSideLine;

int GoalScored(Vector3 ballPos) { // If the ball is within the sidelines... if (!leftSideLine.GetSide(ballPos) && !rightSideLine.GetSide(ballPos)) { // If the ball is over goal line 1 then it's a goal for team 1... if (goalLine1.GetSide(ballPos)) { return 1; } // ...else if the ball is over goal line 2 then it's a goal for team 2. else if (goalLine2.GetSide(ballPos)) { return 2; } }

// Otherwise, it isn't a goal for either team. return 0; } }