-2

I was trying to merge two rotation value with the datatype Quaternion in unity C# script but this error came up. I tried to search for answers but there was either unsolved question or the ones that have been answered is not working.

public GameObject Cube;
public GameObject Img;
public GameObject child;
Quaternion localRotationValue = Cube.transform.localRotation - Img.transform.localRotation;
Instantiate(child, Vector.zero,localRotationValue)

If there is any link of answer is available, that will be helpful too, as I am not able to find a proper answer.

P. Magnusson
  • 82
  • 2
  • 9
P D
  • 23
  • 8

1 Answers1

1

Googled "How to subtract quaternions" and the first link https://forum.unity.com/threads/subtracting-quaternions.317649 has said that you can just multiply by the inverse to achieve it

q1 = q2 * Quaternion.Inverse(q3); 
derHugo
  • 83,094
  • 9
  • 75
  • 115
Nefisto
  • 517
  • 3
  • 9