Baffling Rotation Issue (New Question)

Edit: Figured I’d just use this thread for my next question, which has nothing to do with GUIs.

I’m trying to get a cylinder to rotate depending on a certain variable. (The cylinder is basically an odemeter with a texture on it showing the numbers 0-9. It’s supposed to rotate to point the current number towards the viewer.

Here is my script:

var targetAngle = 0;

function Update () {
	targetAngle = CindyControl.health * 3.6;
	transform.rotation.x = targetAngle;
}

No matter what happens, all that happens is that the cylinder stands up straight (it’s supposed to be lying on its side, so that the Y axis of the cylinder is horizontal). No matter what number I change targetAngle to. No matter which version of transform.rotation I use (.x, .y, .z). No matter whether I use rotation or localRotation or transform.Rotate or Transform.localEulerAngles. Whether I’m using a default cylinder or an imported one. Everything produces a result of the cylinder standing straight up, which does not make any sense to me whatsoever.

Anyone have the slightest idea what’s going on?

The original thread in case anyone still cares:

GUITextures can’t be rotated. You can rotate things in OnGUI by using RotateAroundPivot, but for a clock I’d just keep it simple and make it out of polygons.

–Eric

I guess so. It seems like a pretty simple thing for unity to not be able to do.

Update: what seems to be happening is that after reaching a certain point in the x axis, the object starts increasing in the y and z rotation axis. Which still doesn’t make any sense to me, since I’m only telling it to do stuff with x.

Rotation is quaternions. You want eulerAngles.

–Eric

You should make a new thread. Just editing your original post is super confusing because the other posts refer to your original post.