I read the documentation on it, but I still don’t know exactly how to use it.
I’m trying to check when the player crosses a plane with the plane normal.
How do you get the distance from a plane to a point?
I can’t figure it out, please help.
I read the documentation on it, but I still don’t know exactly how to use it.
I’m trying to check when the player crosses a plane with the plane normal.
How do you get the distance from a plane to a point?
I can’t figure it out, please help.
This is just from my flawed understanding, but it’s better
than nothing.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PointDistance : MonoBehaviour
{
/*The value returned is positive if the point is
on the side of the plane into which the plane's normal
is facing, and negative otherwise.*/
/*This means transform.forward, the blue axis, in front
of it would be positive. And behind it would be negative.*/
//Plane is the object this script is attached to.
private Plane mPlane;
void Start()
{
}
//This is the point that you're getting.
public Transform mPoint;
void Update()
{
//Sets direction of this Plane //Sets position of plane.
mPlane.SetNormalAndPosition(this.transform.forward, this.transform.position);
//Gets the distance from plane to point.
Debug.Log(mPlane.GetDistanceToPoint(mPoint.position));
}
}