I’m once again limited by my ability to transfer a concept from paper to computer.
I’m working on a game where I need to give the user the ability to draw boxes. Right now, I’ve got it working to where you can drag on the background and create meshes as in the screenshot above. My problem is that right now, the vertices on the bottom move straight down along the y-axis, so the different boxes that are drawn have different heights.
So basically, what I need to do is figure out a way to place a third vertex(the bottom left) so that it forms a right angle to the other two vertices(the top left and top right). Here’s some pseudocode to illustrate.
var blockHeight : float = 1.0; //the distance between the top layer of vertices and the bottom layer
var topLeftVertex : Vector3 = oldMousePos; //the point that the mouse was at when the drag started
var topRightVertex : Vector3 = newMousePos; //the point that the mouse is at after the drag
var bottomLeftVertex : Vector3 = topLeftVertex; //NEEDS FIXING
bottomLeftVertex.y -= blockHeight;
So in the code above, depending on the y of the mouse before and after the drag, the actual height of the block may change. So I need to have a right triangle formed by the three vertices in the above code. So I:
var firstLegLength : float = Vector3.Distance(topLeftVertex, topRightVertex);
var hypotenuse = squareroot((blockHeight * blockheight) + (firstLegLength + firstLegLength));
[code]
Now I've got the distance between the top right vertex and the bottom left vertex. Now while working on paper, I would use a compass to draw curves of the two distances, and place my point where the curves intersect. How would I do this in Unity?
(Hoping this isn't entirely opaque)
-Lincoln Green[/img]