- Home /

**Question**by RobertVanDerLeeuw · Mar 13, 2018 at 03:06 PM · c#rotationtransformquaternionif-statements

# Quaternions acting up

For some reason the quaternions in the left and right if statments aren't working properly. The object is supposed to move to the left and right, but it just turns down to 180 degrees.

```
if(Input.GetKeyDown(KeyCode.UpArrow) && SwordReset == 0){
Sword.transform.rotation = new Quaternion(0, 0, 0, 0);
SwingTime = STLength;
}
if(Input.GetKeyDown(KeyCode.DownArrow) && SwordReset == 0){
Sword.transform.rotation = new Quaternion(0, 0, 180, 0);
SwingTime = STLength;
}
if(Input.GetKeyDown(KeyCode.LeftArrow) && SwordReset == 0){
Sword.transform.rotation = new Quaternion(0, 0, 90, 0); //The first issue
SwingTime = STLength;
}
if(Input.GetKeyDown(KeyCode.RightArrow) && SwordReset == 0){
Sword.transform.rotation = new Quaternion(0, 0, 270, 0); //The second issue
SwingTime = STLength;
}
```

**Answer** by TreyH
·
Mar 13, 2018 at 03:10 PM

I think you're confusing *Quaternions* and *Euler Angles*.

This might be what you really want:

```
Sword.transform.rotation = Quaternion.Euler(0, 0, 270);
```

Right, this numberphile video is one of the best, simplest and most straight forward explainations of how a quaternion roughly works. Quaternions have many advantages when compared to euler angles. While euler angles represent 3 seperate rotations around different axes executed in a particular order, one after another, Quaternions can represent an arbitrary rotation as one single operation. While eulerangles may suffer from things like gimbal lock due to the seperate rotations, quaternion do not have this problem. This is one of the main reasons we use them. They simplify combining several rotations into a single rotation.

### 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 i can equal 2 Tranform Rotations? 1 Answer

Rotating a certain axis offsets the other ones? 1 Answer

Flip over an object (smooth transition) 3 Answers

Auto leveling help 0 Answers

Use a single rotation axis of a freely rotating object 1 Answer