diff --git a/spine-ue4/Content/GettingStarted/Assets/Raptor/Textures/raptor.uasset b/spine-ue4/Content/GettingStarted/Assets/Raptor/Textures/raptor.uasset index 780459681..bf3e894ca 100644 Binary files a/spine-ue4/Content/GettingStarted/Assets/Raptor/Textures/raptor.uasset and b/spine-ue4/Content/GettingStarted/Assets/Raptor/Textures/raptor.uasset differ diff --git a/spine-ue4/Content/GettingStarted/Assets/Raptor/raptor.uasset b/spine-ue4/Content/GettingStarted/Assets/Raptor/raptor.uasset index bce1987e7..3b8f6b145 100644 Binary files a/spine-ue4/Content/GettingStarted/Assets/Raptor/raptor.uasset and b/spine-ue4/Content/GettingStarted/Assets/Raptor/raptor.uasset differ diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp index e769ec796..8dabf4250 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp @@ -78,6 +78,7 @@ USpineSkeletonAnimationComponent::USpineSkeletonAnimationComponent () { PrimaryComponentTick.bCanEverTick = true; bTickInEditor = true; bAutoActivate = true; + bAutoPlaying = true; } void USpineSkeletonAnimationComponent::BeginPlay() { @@ -94,7 +95,7 @@ void USpineSkeletonAnimationComponent::TickComponent(float DeltaTime, ELevelTick void USpineSkeletonAnimationComponent::InternalTick(float DeltaTime, bool CallDelegates) { CheckState(); - if (state) { + if (state && bAutoPlaying) { state->update(DeltaTime); state->apply(*skeleton); if (CallDelegates) BeforeUpdateWorldTransform.Broadcast(this); @@ -160,6 +161,36 @@ void USpineSkeletonAnimationComponent::FinishDestroy () { Super::FinishDestroy(); } +void USpineSkeletonAnimationComponent::SetAutoPlay(bool bInAutoPlays) +{ + bAutoPlaying = bInAutoPlays; +} + +void USpineSkeletonAnimationComponent::SetPlaybackTime(float InPlaybackTime, bool bCallDelegates) +{ + CheckState(); + + if (state && state->getCurrent(0)) { + spine::Animation* CurrentAnimation = state->getCurrent(0)->getAnimation(); + const float CurrentTime = state->getCurrent(0)->getTrackTime(); + InPlaybackTime = FMath::Clamp(InPlaybackTime, 0.0f, CurrentAnimation->getDuration()); + const float DeltaTime = InPlaybackTime - CurrentTime; + state->update(DeltaTime); + state->apply(*skeleton); + + //Call delegates and perform the world transform + if (bCallDelegates) + { + BeforeUpdateWorldTransform.Broadcast(this); + } + skeleton->updateWorldTransform(); + if (bCallDelegates) + { + AfterUpdateWorldTransform.Broadcast(this); + } + } +} + void USpineSkeletonAnimationComponent::SetTimeScale(float timeScale) { CheckState(); if (state) state->setTimeScale(timeScale); diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp index 1302179a4..588f700eb 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp @@ -331,4 +331,4 @@ void USpineSkeletonRendererComponent::UpdateMesh(Skeleton* Skeleton) { clipper.clipEnd(); } -#undef LOCTEXT_NAMESPACE +#undef LOCTEXT_NAMESPACE \ No newline at end of file diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonAnimationComponent.h b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonAnimationComponent.h index c02d121bd..303d11efc 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonAnimationComponent.h +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonAnimationComponent.h @@ -194,6 +194,16 @@ public: virtual void TickComponent (float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; virtual void FinishDestroy () override; + + //Added functions for manual configuration + + /* Manages if this skeleton should update automatically or is paused. */ + UFUNCTION(BlueprintCallable, Category="Components|Spine|Animation") + void SetAutoPlay(bool bInAutoPlays); + + /* Directly set the time of the current animation, will clamp to animation range. */ + UFUNCTION(BlueprintCallable, Category = "Components|Spine|Animation") + void SetPlaybackTime(float InPlaybackTime, bool bCallDelegates = true); // Blueprint functions UFUNCTION(BlueprintCallable, Category="Components|Spine|Animation") @@ -255,4 +265,9 @@ protected: // in transit within a blueprint UPROPERTY() TSet trackEntries; + +private: + /* If the animation should update automatically. */ + UPROPERTY() + bool bAutoPlaying; }; diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonRendererComponent.h b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonRendererComponent.h index f32f49c2a..d91375605 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonRendererComponent.h +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonRendererComponent.h @@ -86,9 +86,9 @@ public: UPROPERTY(Category = Spine, EditAnywhere, BlueprintReadWrite) FLinearColor Color = FLinearColor(1, 1, 1, 1); - /** Whether to generate collision geometry for the skeleton, or not. */ - UPROPERTY(Category = Spine, EditAnywhere, BlueprintReadWrite) - bool bCreateCollision; + /** Whether to generate collision geometry for the skeleton, or not. */ + UPROPERTY(Category = Spine, EditAnywhere, BlueprintReadWrite) + bool bCreateCollision; virtual void FinishDestroy() override; @@ -99,4 +99,4 @@ protected: spine::Vector worldVertices; spine::SkeletonClipping clipper; -}; +}; \ No newline at end of file