How to modify the value of an axis without touching to the others ?

Hi,

I’d like to animate the Robot Arm that comes with The Labo project when I press some key. The problem is that I can’t figure how to move the arm part correctly, the body turn well but the arm doesn’t follow the movement when I try do move it.

Here is the code:
enter code herevoid Start () {

		body = GameObject.Find("prop_robotArm_body_001");
		arm =GameObject.Find("prop_robotArm_arm_001");
		
	}
	
	// Update is called once per frame
	void Update () {
		
		
		
		
		if(Input.GetAxis("Horizontal")<-.1){
			
			Quaternion targetAngle=Quaternion.Euler (new Vector3(0f,0f,0f));
			
			body.transform.rotation = Quaternion.Lerp(body.transform.rotation,targetAngle,Time.deltaTime*rotatingSpeed);
		}
		else if(Input.GetAxis("Horizontal")>.1)
		{
			
			Quaternion targetAngle=Quaternion.Euler (new Vector3(0f,180f,0f));
			
			body.transform.rotation = Quaternion.Lerp(body.transform.rotation,targetAngle,Time.deltaTime*rotatingSpeed);
		}
		
		if(Input.GetAxis("Vertical")<-.1){
			
			Quaternion targetAngle=Quaternion.Euler (new Vector3(0f,0f,-30f));
			
			 arm.transform.rotation = Quaternion.Lerp( arm.transform.rotation,targetAngle,Time.deltaTime*rotatingSpeed);
		}
		else if(Input.GetAxis("Vertical")>.1)
		{
			
			Quaternion targetAngle=Quaternion.Euler (new Vector3(0f,0f,30f));
			
			 arm.transform.rotation = Quaternion.Lerp( arm.transform.rotation,targetAngle,Time.deltaTime*rotatingSpeed);
		}
	}

and the result for now :
[11119-capture+d’écran+2013-05-17+à+15.09.40.png|11119]

I’m assuming you want the arm to have relative rotation to the body, and that all these parts share a parent/child relationship. My first suggestion is to use Transform.localRotation rather than Transform.rotation.