How to assign a rotation relative to another object? (221770)

There are Projects A and B. Is it possible to assign a rotation to an object (A) relative to one of the sub-project objects (B) without using SetParent
help me What to do, what to look for?

what's a project in your terms?

–

3 Answers

3

If you want to get rotation A relative to rotation B, assuming A and B are quaternion rotations,
then I believe it’s

Quaternion.Inverse(B) * A;

Thanks! You've helped me after 2 days of suffering with quaternions...

–

I believe that what you are looking for is this : Unity - Scripting API: Transform.RotateAround

EDIT : Just assign the transform.rotation of object A to object B then. If you want to add another rotation on top of that, multiply by another quaternion.

I do not think this is it! I generally need the rotation of the object to be the same as the rotation of another object

–

thanks for the answer

–

This is what I was looking for!

–

Your question is a bit confusing but if you are looking for object B to have the same rotation of object A plus an additional arbitrary rotation you can do

B. transform.rotation = A.transform.rotation * Quaternion.Euler(0f, 45f, 0f);

This would set B’s rotation to A’s rotation plus an additional 45 degrees.

Thanks for the answer, it helped me

–