Math3D.LookRotationExtended C# (CSharp) Method

LookRotationExtended() public static method

public static LookRotationExtended ( GameObject &gameObjectInOut, Vector3 alignWithVector, Vector3 alignWithNormal, Vector3 customForward, Vector3 customUp ) : void
gameObjectInOut GameObject
alignWithVector Vector3
alignWithNormal Vector3
customForward Vector3
customUp Vector3
return void
    public static void LookRotationExtended(ref GameObject gameObjectInOut, Vector3 alignWithVector, Vector3 alignWithNormal, Vector3 customForward, Vector3 customUp)
    {
        //Set the rotation of the destination
        Quaternion rotationA = Quaternion.LookRotation(alignWithVector, alignWithNormal);

        //Set the rotation of the custom normal and up vectors.
        //When using the default LookRotation function, this would be hard coded to the forward and up vector.
        Quaternion rotationB = Quaternion.LookRotation(customForward, customUp);

        //Calculate the rotation
        gameObjectInOut.transform.rotation =  rotationA * Quaternion.Inverse(rotationB);
    }