I have a rectangular object (for now), with children placed partially in it in its forward, up, and right sides (to make rotations easier to track).
I am trying to get the object to rotate according to 3 points in space. One is the origin (0,0,0), one is in the forward direction (0,0,1), and one is in the right direction (1,0,0).
The origin and forward direction are how I define the origin and direction, so these coordinates are local. I assume for now that the right direction is correct for now.
My simple solution was to set transform.forward = (forward-origin);
and transform.right = (right-origin);
(where the points are given in global coordinates).
My problem with this is that the rectangular object won't roll around its forward direction. I'm not great with geometry, but I can't get past the thought that setting right
ought to solve that problem.
I was, however, not surprised to see that trying to set transform.up
as the cross-product of those two made things worse and the object was no longer facing in the forward direction.
So,
- Why doesn't the combination of
forward
andright
account for this rolling? - What if
right
weren't exactly right? I'm assuming simply normalizing it againstforward
would do it (and with unity, I could also getup
out of it with one function call), but I'm not certain.