Help with changing angle.

My code is getting the error; BCE0022: Cannot convert ;float; to ;UnityEngine.Quaternion;.

 function Update () {
 transform.rotation=transform.rotation.y+0.1;
 rigidbody.AddForce(Input.GetAxis("Horizontal"),0,0);
 }

My idea is this- the laser fires when you hold space, but it only shoots in one direction. I have added this so when you press the arrow keys the turret moves.

Thanks

Transform.rotation is a 4-dimensional quaternion, and the y component is not related to the y axis. Don’t alter it unless you understand quaternions. Even if you were to do it, you can’t get rotation.y and assign to rotation, you’d have to assign to rotation.y. Also adding 0.1 every frame is a no-no since it’s framerate-dependent. You must use Time.deltaTime. Anyway, no doubt you want the Transform.Rotate function.

Transform.rotation is a quaternion, a strange creature whose XYZ components have nothing to do with the nice angles you see in the Rotation field (those are the localEulerAngles). You must not modify the components of a quaternion directly, unless you know exactly what you’re doing (and I suspect that you don’t know, as 99.9% of all Unity users). By the way, the second line will just accelerate the turret left or right (provided that the turret is a rigidbody, of course; if not, you will get lots of runtime errors). Is this what you wanna do?

Supposing that you just want to rotate the turret under arrow keys control, do the following:

var turnSpeed: float = 60; // turn speed in degrees/second

function Update(){
  transform.Rotate(0, Input.GetAxis("Horizontal") * turnSpeed * Time.deltaTime, 0);
}