Search code examples
unreal-engine4unreal-blueprint

Unreal Live Link Face Plugin: How to detect when the face is out of the camera?


I’m following the Recording Facial Animation from an iPhone X tutorial with Unreal Engine 4 and capturing and presenting my face movement successfully.
But when my face is out of the camera, the pose in the editor will stuck in the last frame.
How could I detect the lost of live animation data so to play a prerecorded animation?


Solution

  • I have figured it out. Just use ILiveLinkClient::IsSubjectValid(SubjectName); method from the LiveLinkPlugin source in c++ or export it to Blueprint:

    class DAZTOUE4_API UMyBlueprintFunctionLibrary : 
    public UBlueprintFunctionLibrary
    {
        GENERATED_BODY()
    
        UFUNCTION(BlueprintCallable, Category = "MyVirtualCharacter")
        static bool IsLiveLinkSubjectValid(const FLiveLinkSubjectName SubjectName);
    };
    
    bool UMyBlueprintFunctionLibrary::IsLiveLinkSubjectValid(const FLiveLinkSubjectName SubjectName)
    {
        IModularFeatures& ModularFeatures = IModularFeatures::Get();
        if (ModularFeatures.IsModularFeatureAvailable(ILiveLinkClient::ModularFeatureName))
        {
            ILiveLinkClient& LiveLinkClient = ModularFeatures.GetModularFeature<ILiveLinkClient>(ILiveLinkClient::ModularFeatureName);
            return LiveLinkClient.IsSubjectValid(SubjectName);
        }
        return false;
    }