After research i found that transform.TransformPoint(Vector3) method is used to convert Vector to world space. But for me that method do not change. I have Box class:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Box: MonoBehaviour
{
public string named;
public string id;
public Vector3 dimensions;
public Vector3 boxLeftBottomFront;
public Vector3 boxRightBottomFront;
public Vector3 boxLeftTopFront;
public Vector3 boxRightTopFront;
public Vector3 boxLeftBottomBack;
public Vector3 boxRightBottomBack;
public Vector3 boxLeftTopBack;
public Vector3 boxRightTopBack;
private void Start()
{
this.GetComponent<MeshFilter>().mesh.recalculateMeshByBounds(dimensions);
boxLeftBottomFront = this.GetComponent<MeshFilter>().mesh.vertices[3];
boxRightBottomFront = this.GetComponent<MeshFilter>().mesh.vertices[2];
boxLeftTopFront = this.GetComponent<MeshFilter>().mesh.vertices[4];
boxRightTopFront = this.GetComponent<MeshFilter>().mesh.vertices[12];
boxLeftBottomBack = this.GetComponent<MeshFilter>().mesh.vertices[0];
boxRightBottomBack = this.GetComponent<MeshFilter>().mesh.vertices[1];
boxLeftTopBack = this.GetComponent<MeshFilter>().mesh.vertices[5];
boxRightTopBack = this.GetComponent<MeshFilter>().mesh.vertices[9];
}
private void Update()
{
}
}
These vectors in Box class is local Position. Then i want to access Box vertices from another script and convert vertice to world space:
private void AllocateSpace()
{
Vector3 vector = transform.TransformPoint(packedBoxes[packedBoxes.Count - 1].GetComponent<Box>().boxRightBottomBack);
Debug.Log(vector);
pivotPoint = vector;
Debug.Log(pivotPoint);
}
In Debug.Log
i get same result, vector is not converted to world space. What i am doing wrong? Thank you.
Comments
Post a Comment