Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since you can easily get the <a href="http://docs.unity3d.com/Documentation/ScriptReference/Bounds.html" rel="nofollow">BoxCollider's <em>centre</em> and <em>extents</em></a> you can get the local vertex position easily by adding or subtracting the extent from the centre, then transforming it into global world space with a method like <a href="http://docs.unity3d.com/Documentation/ScriptReference/Transform.TransformPoint.html" rel="nofollow">Vector3.TransformPoint()</a></p> <p>The following script prints the global position of each vertex of a BoxCollider attached to the same GameObject as the script, every Update() call.</p> <pre><code>using System.Collections; public class DebugPrintColliderVertices : MonoBehaviour { const uint NUM_VERTICES = 8; private BoxCollider boxCollider; private Transform[] vertices; void Awake() { boxCollider = (BoxCollider)this.gameObject.GetComponent(typeof(BoxCollider)); if (boxCollider == null) { Debug.Log ("Collider not found on " + this.gameObject.name + ". Ending script."); this.enabled = false; } vertices = new Transform[NUM_VERTICES]; } void Update() { Vector3 colliderCentre = boxCollider.center; Vector3 colliderExtents = boxCollider.extents; for (int i = 0; i != NUM_VERTICES ; ++i) { Vector3 extents = colliderExtents; extents.Scale (new Vector3((i &amp; 1) == 0 ? 1 : -1, (i &amp; 2) == 0 ? 1 : -1, (i &amp; 4) == 0 ? 1 : -1)); Vector3 vertexPosLocal = colliderCentre + extents; Vector3 vertexPosGlobal = boxCollider.transform.TransformPoint(vertexPosLocal); // display vector3 to six decimal places Debug.Log ("Vertex " + i + " @ " + vertexPosGlobal.ToString("F6")); } } } </code></pre> <p>Note that the BoxCollider's size is multiplied by the transform.scale of the GameObject it's attached to. I haven't included that calculation in said script, but finding the overall rotation/scale should be fairly trivial from this point.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload