- Home /
The mathmatic inside transform.setparent and remain world position? How local trans value calculated?
Here is a simple scene with a camera looks at the cube:
the cube position and rotation is (0,0,0) and with a scale (s1,s2,s3). the camera is looking at the cube and the transform is (p1,p2,p3)(r1,r2,r3)(1,1,1).
Now, to achieve the same view, but let camera position and rotation at (0,0,0), how to calculate the correct transform for the cube?
It is NOT just simply reverse position and rotation, I have tried. I can achieve this goal in the editor by re-targeting the cube parent as the camera, and then reset the camera position and then move the cube back to scene root, the cube's transform now contains the correct value, but how is the inside job works?
when A.setparent(B) remain world position, A's local position and rotation changed, so what is the fomula to change local transform?
A.localposition = fomula0(A,B); A.localrotation = fomula1(A,B);
Your answer
Follow this Question
Related Questions
How to ROTATE an object without slowing the ends (lerp) 3 Answers
Smooth transform position and rotation 1 Answer
Rotation not going past 180? 2 Answers
why update function doesn't work on the transform.Rotate function 0 Answers
Following another object's position/rotation like parent/child relationship? 4 Answers