Set transform.rotation to 2 vectors at the same time?

Hi, I have an object which should always forcibly face the global X direction. However, it should also align its’ x, y or z (I don’t care which) axis to a vector3. How could I do that?

Right now if I set 2 object.transform.(forward/right/up) the later call pretty much screwes up what the first one did.

If your object should always be aligned with the x axis it can only be rotated around the x axis. Thats why I’m not sure if I understood that correctly.

Anyhow, if you want to rotate an object around it’s own forward you could use RotateAround. I hope the following snippet will help you.

float rotationSpeed = 1;
void Start () 
{
    transform.forward = Vector3.right;
}

void Update () 
{
    transform.RotateAround(transform.forward, rotationSpeed * Time.deltaTime);
}