- Home /

# Rotation values problem

Hi,

I have a wheel initially rotated at 0,0,0 euler angles (the front is oriented towards z-). By pressing the up key RelativeTorque is added, so that it rotates the wheel around the x axis by a certain amount. But what I noticed is that the other global euler angles (y and z) are changing too. The x rotation firstly decrements from 360 to 270 and when it reaches these 270 degrees, the y and z angles instantly become 180 degrees. The process of rotation continues - the x angle starts to increment from 270 and when it reaches 90 degrees y and z angles instantly equal 0, then the x angle decrements from 90 degrees to 360 degrees. And the process starts over. It all takes place with only the up key pressed. This is extremely frustrating, as I want to add Torque around the y axes, but the y angle changes resulting in irregular rotation around all global axes. Does anyone know any solution for this problem?

I'm not sure what's your real problem here and what is representation. Euler angle values like the ones you describe are derived from the Quaternion. There are multiple euler angle representation for any physical rotation, and Unity will 1) change representations on you, and 2) the values may not be ones you expect. For example, do this:

```
transform.eulerAngles = Vector3(180,0,0);
Debug.Log(transform.eulerAngles);
```

What is output is (0,180,180)...the same physical rotation in a different representation. So I think there are two problems here, one of representation and some other real problem with irregular rotation. What forces are acting on the wheel...collisions, friction, movement? Does the wheel turn?

The wheel should rotate in all directions. Rotation around x axis is controlled with up and down arrow keys, and rotation around y axis is changed with right and left arrow keys. The z rotation will be changed upon the object's position in the scene. The wheel is a rigidbody affected by gravity with a mesh collider (the wheel collider didn't work for me - it's not a standard wheel let's say :) ).

I am still not 100% familiar with Quaternions and I really don't know if they can help me in this matter.

EDIT: I forgot, that I'd like everything to occur in a completely physical way - no raw rotation or anything like that - that is I would like to control this object only using torque, forces and gravity.

I don't think Quaternions are a solution to your problem, just that the fact the number are changing in what you view as strange ways is not necessarily the basis for your problem but instead an artifact that rotations internally are stored as Quaternions. It is probably some force interaction in the scene that is causing your issues. I cannot visualize the wrong or right behavior here, but you will likely have to play some games modifying the Rigidbody.angularVelocity. I've seen problems like this one before...someone trying to do a bicycle the last time I saw it. I'm not sure if he ever solved his problems.

I really start thinking that I will have to quit actualizing my idea. I tried every Quaternion, rotation, rigidbody variables, functions etc. and I feel a bit helpless. Is there really no possibility of rotating an object absolutely globally with each rotation axis completely independent?

I hear your frustration. People cannot help you unless they have a clear idea of the problem. I suggest you post a package with a very simple example of what you are trying to achieve. Then write a clear description of what is going wrong in the example and how you want it to behave when it is working correctly. The whole point of my original comment is that the angles you describe may be meaningless in terms of the problem, and we don't have much more information about the problem.

**Answer** by amaceika
·
Nov 13, 2013 at 03:35 PM

If you are using a rigidbody try locking the Rotation of the axis's you don't wish to rotate. You may want to look at this instead of torque. Rigidbody.AddForceAtPosition

Actually, the first solution won't work, because I want to rotate the object around the other axes, but the rotation around x axis must be absolutely independent and other ones must also be independent. Because, if adding torque around x axis makes the wheel move forward, then to steer with it, it must have torque added around the y axis. Freezing rotation around given axes will simply forbid me to do what I want here. AddForceAtPosition works badly in this case as well, because it also affects the position of the object, not only its rotation.

I also am having single axis rotation issues with rotate and localrotate. Check this out

I hope this gets around so we can solve this. I believe that some of the inexperienced are not seeing this and end up with addressing a problem on top of a problem similar to this.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

How to Rotate Object around point only 90 Degree. 1 Answer

Rotate object based on FPSCamera 1 Answer

Reletive rotation problems. (C#) 2 Answers

2D - Rotate object based on touch moved (diff between touches) 0 Answers

How can you make a 2D object move based on rotation, and rotate while moving? 1 Answer