I feel like this is really simple, but for the life of me can't figure it out. I created a class called Triangle that stores three points. Whenever I create a new triangle, the values that are stored are not the ones I give it. For instance, here is the debug log after I store Vector3.up, Vector3.down, and Vector3.forward:
![alt text][1]
Here's my code:
public class TriangulatePoints : MonoBehaviour
{
[SerializeField] GameObject[] nodes = new GameObject[3];
[SerializeField] Triangle triangleOne;
// Start is called before the first frame update
void Start()
{
triangleOne = new Triangle(Vector3.up, Vector3.down, Vector3.forward);
Debug.Log("Triangle point one " + triangleOne.pointOne);
Debug.Log("Triangle point two: " + triangleOne.pointTwo);
Debug.Log("Triangle point three " + triangleOne.pointThree);
}
// Update is called once per frame
void Update()
{
}
}
public class Triangle : MonoBehaviour
{
public Vector3 pointOne;
public Vector3 pointTwo;
public Vector3 pointThree;
public Triangle(Vector3 firstPoint, Vector3 secondPoint, Vector3 thirdPoint)
{
pointOne = firstPoint;
pointTwo = secondPoint;
pointTwo = thirdPoint;
}
}
[1]: /storage/temp/154091-debug.png
↧