How do I make one transform rotation the same as anothers?

Right now I’m trying to take my cameras X rotation and make that my characters right forearm rotation. Can anyone help me with it? I keep getting errors when I try different things.

I can’t simply do rightForearmRotation.z = cameraRotation.x; (Mind you, I’m using C#)

If a component of a vector is read only (like transform.position), you can use a temporary vector, modify it and then replace the original vector with it.

Vector3 temp = transform.position;
temp.z = target.transform.position.x;
transform.position = temp;

But in this case, you can simply do this (methinks):

transform.rotation = Quaternion.Euler(transform.rotation.x, transfom.rotation.y, target.transform.rotation.x);

Since Quaternion.Euler already returns a new Quaternion.

Modifying the components of a Quaternion directly is a bad idea in any case, unless you know exactly how Quaternions work.

public GameObject cube1;
public GameObject cube2;

	// Use this for initialization
	void Start () 
	{
		cube1.transform.rotation = cube2.transform.rotation;
	
	}

For checking this script create a new scene and take 2 cubes…then rotate the 2nd cube as you wish…Drag this script to cube 1…assign both cubes to inspector panel…Hit play and Done…Cube is Rotated to Rotation of Cube 2…Enjoy…If found useful then don’t forget to mark the answer…