Getting a point on a rotated cube

I’m currently making a game for 7drts, and I need to get the Vector3 position of the left and right side of a rectangular prism game object that is rotated.

For example, here’s an image to describe what I need. I need to calculate the Vector3 of the points circled by the two red dots.

1304513--60846--$unity image.png

Does anybody know how I would go about doing this?

PS: I use C#, but I don’t mind translating Javascript or Boo

Please let me know if my post doesn’t make sense!

Thanks! :slight_smile:

If you can I’d just put another GameObject on the point as a child of the rectangle. Then in your script expose a public Transform pointTransform variable, hook it up in the editor and presto! You can then just go

pointTransform.position

If not then you can get the half width of the rectangle

Vector3 point = new Vector3( 0.5f * width, 0, 0 );

and then transform it from local space to world space using the rectangle transform.

point = transform.localToWorldMatrix * point;

I’m pretty sure that would do it… Someone please correct me if I’m wrong.

Wow, that was really simple, I’m still getting used to Unity. Thanks for the solution!