This site uses strictly necessary cookies. More Information

X# I want to rotate a plane towards a normal of 3 Vectors/Points

Hi! Im am trying to create a plane that is defined by 3 points, one of them you can reposition with your mouse. The other is calculated so that the 3 Points form a plane that is tangent to a cone.

I don't know how to create a plane that has those three points/Vectors (like this)

What I tried to do was get the normal of these three points (point v, point p, point t) and set the rotation of the plane to that normal pointing towards the top of the plane:

The result I get from this, is the plane switching between the intended rotation and reset rotation every frame. here is the whole code:

```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TangentPlane : MonoBehaviour
{
//Point Vectors
public Vector3 tPoint;
public Vector3 vPoint;
public Vector3 pPoint;
private Vector3 sideA;
private Vector3 SideB;
public Vector3 planeNormal;
// Horizontal Plane
private GameObject TangentEquation;
private bool horizontalPlane;
private bool perfilTangent;
void Update()
{
//Horizontal Plane
TangentEquation = GameObject.FindGameObjectWithTag("Tangent");
horizontalPlane = TangentEquation.GetComponent<TangentEquation>().horizontalPlane;
perfilTangent = TangentEquation.GetComponent<TangentEquation>().perfilTangent;
//Points
tPoint = GameObject.FindGameObjectWithTag("Tangent").transform.position;
vPoint = GameObject.FindGameObjectWithTag("VPoint").transform.position;
pPoint = GameObject.FindGameObjectWithTag("P").transform.position;
// Establish the difference betwen points
sideA = tPoint - vPoint;
SideB = pPoint - vPoint;
//calculate the normal
planeNormal = (Vector3.Cross(sideA, SideB)).normalized;
transform.rotation = Quaternion.FromToRotation(transform.up, planeNormal);
if(Input.GetMouseButtonUp(0))
{
if (horizontalPlane == true)
{ }
else if (perfilTangent == true)
{ }
else
{
}
}
}
}
```

Blockquote

**Answer** by Sunatic
·
Apr 20 at 09:29 AM

If you edit this code `transform.rotation = Quaternion.FromToRotation(transform.up, planeNormal);`

For this `transform.rotation = Quaternion.FromToRotation(transform.position, planeNormal); `

You get the desired result :)

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.