I have Vector3 variable and I want to rotate it so that Y-axis will be pointing up. How to do it?

EDIT: sorry, Y-axis has to be 0 (so the resulting Vector is on XY plane)(but it has to have same magniude of course)

I have Vector3 variable and I want to rotate it so that Y-axis will be pointing up. How to do it?

EDIT: sorry, Y-axis has to be 0 (so the resulting Vector is on XY plane)(but it has to have same magniude of course)

Given a vector v at an arbitrary angle, youu can do:

```
v = Quaternion.FromToRotation(v, Vector3.up) * v;
```

Found my answer:

```
float mag = v.magnitude;
v -= new Vector3 (0,v.y,0); // set y to 0
v.Normalize();
v *= mag //multiply by mag (so magnitude is same as before)
```