Question by
frankglinski · Jul 12, 2017 at 10:55 PM ·
c#rotationquaternion
Adding one Objects Rotation To Another Objects Rotation
I want to add one objects Y Rotation to another Objects Y Rotation. I currently have it adding the roatation however it is adding it continuously, and i want it to do it for 1 frame.`using System.Collections; using System.Collections.Generic; using UnityEngine;
public class RotationAdd_V2 : MonoBehaviour {
public GameObject Leader;
public GameObject Follower;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Follower.transform.rotation = Quaternion.Euler(Follower.transform.rotation.eulerAngles.x, Follower.transform.rotation.eulerAngles.y + Leader.transform.rotation.eulerAngles.y, Follower.transform.rotation.eulerAngles.z);
}
}
Comment
Answer by Kishotta · Jul 12, 2017 at 11:03 PM
You can apply multiple quaternion rotations by multiplying them together.
The order determines which rotation is applied first:
transform.rotation = FirstQuaternion * SecondQuaternion * ThirdQuaternion.
Your answer
![](https://koobas.hobune.stream/wayback/20220612130129im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to rotate a camera slowly along a tween? 1 Answer
Grabbing the Relative eulerAngles.y of a Rotation 1 Answer
Smooth 90 degree rotation on keypress 3 Answers
Clamp a rotation in unity 0 Answers
-= Time.deltaTime 1 Answer