- Home /
Different results with Matrix4x4.MultiplyPoint and Matrix4x4.rotation
Hello,
I have a GameObject GO1
representing a Camera
with four spheres (s1_1, s1_2, s1_3, s1_3)
as children. Then I have another GameObject GO2
with four more spheres (s2_1, s2_2, s2_3 , s2_4)
as children. The GO1
and GO2
have slightly different positions and rotations. Similar, the spheres of GO1
and GO2
also slightly different distributed.
I calculate the rotation and translation matrix ( Matrix4x4
) to move the spheres of GO2
(s2_1, s2_2, s2_3 , s2_4)
to get as close as possible to the respective spheres of GO_1
(s1_1, s1_2, s1_3, s1_3)
. Then I use the Matrix4x4.MultiplyPoint
with each sphere. This works fine.
However, I would like to just rotate and move GO2
and not each single sphere using the matrix that I calculated. To do so, I use Matrix4x4.rotation
and I multiply it with the transform.rotation
of GO2
. I thought that I should get the same result but it doesn't. Does anyone have an idea on how to rotate GO2
using the rotation matrix? If I use Matrix4x4.MultiplyPoint
with GO2
it just changes the position but not its rotation and thus the children are not rotated accordingly.
Thanks!
Do you mean transform.rotation = matrix.rotation
?
Performs full transformation of a vector (so scale, rotation and translation)Matrix4x4.MultiplyPoint
Extracts a rotation component from a 4x4 matrix. Returns amatrix4x4.rotation
Quaternion
.
I have tried transform.rotation = matrix.rotation and transform.rotation *= matrix.rotation but both give wrong results.
I can try to help but you need to show some code here. It's hard to guess anything more from your description as it is now.
Your answer
