copy only Y axis rotation of an object?
Hey. i want to copy the rotation of an object (master) i thought it would work like this:
using UnityEngine;
using System.Collections;
public class copyrotation_x : MonoBehaviour {
public GameObject master;
void Update () {
transform.rotation = Quaternion.Euler(transform.rotation.x, master.transform.rotation.y, transform.rotation.x);
}
}
but somehow it doesent copy the rotation? could you tell me why? thanks!
Answer by OncaLupe · Dec 14, 2015 at 12:19 AM
rotation
is a Quaternion, which has 4 elements (x, y, z, w), however they do not correspond to the (x, y, z) of normal 3-axis Euler angles. You need to use rotation.eulerAngles.x
to get the values you want.
Your answer
Follow this Question
Related Questions
How to make my object facing the direction of its movement? 2D 0 Answers
Why does my weapon rotation change after hitting play? 0 Answers
DESPERATE How to align transform.up with another vector3 (direction) ? 1 Answer
Player rotates spastically on all axes when camera is turned 0 Answers
Real life frame position to relative position to camera rotation 0 Answers