# Code doesn't work - Moving y Rotation

Hi, I’m having issues with my stabilization script. The thing I want to make is that the Y axis of the head is moving left and right, thus moving the Y axis of the camera, and I want to remove that movement in the camera.

I cannot remove the camera from the head as it is needed for movement, but want to reduce the “jitter”, so I need to calculate for example:
If the head moves +3 in y (The Head Part) to reduce -3 in y (Camera), but that the Camera Y is still effected by the Player’s Y, if he moves his body for +30 in Y.

• Player (Negate[1])

• Camera (CameraStab)

What I’ve tried (this works with z and x axis)

``````CameraStab.rotation.y = (Negate[0].transform.localRotation.y - 360)- (Negate[1].transform.localRotation.y - 360);
``````

Rotation is a quarterion. Don’t touch it’s y directly. Instead use Euler angles.

Can you explain me how? I would love to learn it.

Thanks but I code in Java, also can someone please try at least to make the code? I tried Quaternions, but didn’t get the results I needed.

One moment while I search for the face palm emoticon.

Step 1. Stop using UnityScript.

1. The video is more the theory than the actual code. Euler angles allow you to use vector3s…Instead of handling the rotation using Quaternion, you can use the LocalEulerAngle which basically is a vector3 convert function which allows you to specify rotation values.

If you wanted to change the rotation on the y, you could simple say:

transform.localeulerangles.y = blah. (if you’re using javascript I think this is legal…Not really sure.)

1. No, Javascript is better for me, as I use it in both Unity and .js for internet files.

2. Thanks, I’ll try that. I know it goes troguht theory, I watched it, but since this isn’t just that, I needed help.

1 Like