# Transform rotation

Hi, I have a problem with the transform.rotation. I want one object to repeat an other object’s rotations, but not completely, I need the rotation on the y Axis to be modified.
This is what I have right now

``````rotx = GameObject.FindWithTag("knee").transform.rotation.x;
roty = GameObject.FindWithTag("knee").transform.rotation.y;
rotz = GameObject.FindWithTag("knee").transform.rotation.z;
//print(rotx + " " + roty + " " + rotz);
this.transform.rotation = GameObject.FindWithTag("knee").transform.rotation;
``````

So, this code works great right now, I need to modify it in some way as to apply each axis rotation individually, what I would like it to look like is something like this

``````this.transform.rotation.x = rotx;
this.transform.rotation.y = roty;
this.transform.rotation.z = rotz;
``````

Is this possible to achieve in any way?

Thanks Another way is to store the current Rotation value and modify as needed and then finally reapply at the end of the method i.e.

``````Quaternion curRotation = this.transform.rotation;
// Order is important!! A rotation that rotates euler.z degrees around the z axis, euler.x degrees around the x axis, and euler.y degrees around the y axis (in that order).
curRotation.eulearAngles.z += rotz;
curRotation.eulearAngles.x += rotx;
curRotation.eulearAngles.y += roty;
this.transform.rotation = curRotation;
``````

In your case though it can be simplified to basically:

``````using UnityEngine;
using System.Collections;

public class RotateScript : MonoBehaviour
{

public Transform otherTrans;

void Start()
{
if(otherTrans == null)
{
enabled = false;
return;
}

}

void Update()
{

float rotx = otherTrans.rotation.eulerAngles.x;
float roty = otherTrans.rotation.eulerAngles.y;
float rotz = otherTrans.rotation.eulerAngles.z;
//print(rotx + " " + roty + " " + rotz);

// Tweak roty in some way -- i.e.
roty = 0.0f;

//Then apply the new values
this.transform.rotation = Quaternion.Euler(rotx, roty, rotz);
}
}
``````

Yes, but you will have to store them in a temporary variable or create one on the fly when setting your new rotation.

``````this.transform.rotation = GameObject.FindWithTag("knee").transform.rotation;
``````this.transform.rotation = new Quaternion(rotx, roty, rotz, rotw);
From there you can modify any of the passed in parameters as you please 