Announcement

Collapse
No announcement yet.

SkeletalMeshComponent::PlayAnimation() blocks UAnimInstance::BlueprintUpdateAnimation?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    SkeletalMeshComponent::PlayAnimation() blocks UAnimInstance::BlueprintUpdateAnimation?

    Hi, Unreal gurus,

    Now that I'm especially interested in animation architecture of Unreal.
    I decide to implement my own AnimInstance to gain more insight.

    Here are what I do to trigger my problem:
    1. Follow Rama's helpful article at https://wiki.unrealengine.com/Animat...a_Tick_Updates to create a UAnimInstance and a animation blueprint.
    2. Add a simple function named "setDefaultBlendSpace" as the following:
    Code:
    void UAnimInst_Mannequin::setDefaultBlendSpace( UBlendSpace1D *input )
    {
        blendspaceDefault = input;
    
        if( mesh ) {
                GEngine->AddOnScreenDebugMessage( -1, 10.0f, FColor::Green, "Start playing BlendSpace1D" );
                mesh->PlayAnimation( blendspaceDefault, true );  // true: do LOOP
            }
    }
    3. Connect the setDefaultBlendSpace() to BeginPlay in Animation blueprint to pass a BlendSpace1D.

    Problem:
    BlueprintUpdateAnimation( At least in Blueprint ) is NOT trigger anymore to update the pose.

    Is USkeletalMeshComponent::PlayAnimation() a blocking call or something?
    All I want to do is just set a blend space as idle pose, and pass speed parameter later.
    Or do you recommend some other approach to do similar thing in C++?

    Thank you.
    Last edited by sbbg; 10-26-2017, 10:46 PM. Reason: Rephrase question and add tags.

    #2
    Did you override
    virtual void NativeUpdateAnimation(float DeltaTimeX) override; And call Super in it?
    https://www.casualdistractiongames.com

    Comment


      #3
      Originally posted by OptimisticMonkey View Post
      Did you override
      virtual void NativeUpdateAnimation(float DeltaTimeX) override; And call Super in it?
      Yes, I did, sir.
      Thank you for reminding anyway.

      Comment


        #4
        Hi,

        I dig further into source code of SkeletalMeshComponent::PlayAnimation() and found the function call these:
        Code:
        void USkeletalMeshComponent::PlayAnimation(class UAnimationAsset* NewAnimToPlay, bool bLooping)
        {
               SetAnimationMode(EAnimationMode::AnimationSingleNode);
               SetAnimation(NewAnimToPlay);
               Play(bLooping);
        }
        while the later 2 look fine, but I found the first call look conflict with what am I trying now.
        (I still hope the character run the blueprint inherited from the animation instance.)

        I tried use the later 2 calls instead of call USkeletalMeshComponent::PlayAnimation(), but it didn't work and the mesh remain T-pose.
        If I really set the Animation mode to animation asset in character blueprint, the NativeUpdateAnimation() back to life as expected, but the BlendSpace does not work either.

        I'm completely lost here. Is this a wrong place to play a BlendSpace? (I know I can do it with Character class, but I want to extract it instead of doing this in every character.)
        I know I can update the pose or something in NativeUpdateAnimation(), but must I really do this like reading a single pose from the asset and post them to skeletal mesh for every frame?



        Last edited by sbbg; 10-27-2017, 02:50 AM.

        Comment


          #5
          Ahh yes - That call is to play a single animation directly. This bypasses the animation blueprint.

          If you want to use your custom anim class, you want to use
          EAnimationMode::AnimationBlueprint
          This is easily configured on the blueprint that has the skeletalmesh in the animation section. Just set the animation mode to Use Animation Blueprint and set the AnimClass to your custom class
          https://www.casualdistractiongames.com

          Comment


            #6
            Originally posted by OptimisticMonkey View Post
            Ahh yes - That call is to play a single animation directly. This bypasses the animation blueprint.

            If you want to use your custom anim class, you want to use
            EAnimationMode::AnimationBlueprint
            This is easily configured on the blueprint that has the skeletalmesh in the animation section. Just set the animation mode to Use Animation Blueprint and set the AnimClass to your custom class
            Thank you for keep replying, sir.
            You truly show the bright side of humanity to me.

            Now that it comes to custom UAnimBlueprint, I found that I have very difficult time finding any documents about this topic.

            To go into the details, these are:
            1. I know there is some API like FAnimationNode or FAnimNode_StateMachine. But I cannot understand how to link 2 states or produce a state machine by code. Or how to assign a BlendSpace/AnimationSequence to a state..., etc.
            2. How to produce a AninGraph(in UE4Editor's terminology) by C++ to associate it with Animation Blueprint.
            3. How to link 2 nodes in the AnimGraph
            4. How to output to the Final Pose( in UE4Editor's terminology )

            Sorry that I have to bring forth more question. I will also set out on my own to dig further.
            If someone have any tip or document to share, it will be greatly appreciated.

            Comment

            Working...
            X