- Home /
How i can equal 2 Tranform Rotations?
I need to equal 2 Rotations Example: Object A: X = 45º Y = 0 Z = 0 I need Object B to be equal to this
I tried this:
Quaternion tempRot = this.transform.rotation;
shipRotInd.Rotate(tempRot.eulerAngles);
//In this case the Object B spins very fast.
and this
shipRotInd.rotation = this.transform.rotation;
//In this case de Object B goes X = 270º for no reason
Try storing tempRot as a Vector3 with eulerangles and passing that to the other.
Vector3 tempRot = new Vector3 (transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z);
Quaternion bRotation = = Quaternion.Euler (tempRot);
Once you have bRotation setup, you can then force B to use that as the rotation.
Answer by maccabbe · Jun 14, 2015 at 10:14 PM
If Transform.rotation sets the global rotation (relative to the world) while inspector displays local rotation (relative to the objects. parent). So if
shipRotInd.rotation = this.transform.rotation;
is not setting the rotations to be the same then most likely they have parents with different rotations but their rotations (in terms of the world) are still the same
If you want to set the local rotations to be the same (this would also set the rotations displayed by the inspector to be the same) use Transfrom.localRotation
shipRotInd.localRotation = this.transform.localRotation;
Your answer
Follow this Question
Related Questions
transform.Rotate will not work 1 Answer
Moving Camera on player stop then move and rotate to separate point? 0 Answers
Rotation Jumping values (0 to 180) 1 Answer
How to rotate on one axis while keeping the other axes open to be rotated by other scripts? 1 Answer
Use a single rotation axis of a freely rotating object 1 Answer