diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineBoneDriverComponent.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineBoneDriverComponent.cpp index b2143b83b1..9f8aece718 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineBoneDriverComponent.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineBoneDriverComponent.cpp @@ -41,9 +41,14 @@ void USpineBoneDriverComponent::BeginPlay () { } void USpineBoneDriverComponent::BeforeUpdateWorldTransform(USpineSkeletonComponent* skeleton) { - AActor* owner = GetOwner(); - if (owner && skeleton == lastBoundComponent) { - skeleton->SetBoneWorldPosition(BoneName, owner->GetActorLocation() ); + if (skeleton == lastBoundComponent) { + if (UseComponentTransform) { + skeleton->SetBoneWorldPosition(BoneName, GetComponentLocation()); + } + else { + AActor* owner = GetOwner(); + if (owner) skeleton->SetBoneWorldPosition(BoneName, owner->GetActorLocation()); + } } } diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineBoneFollowerComponent.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineBoneFollowerComponent.cpp index 3795b48505..5fdf036232 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineBoneFollowerComponent.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineBoneFollowerComponent.cpp @@ -43,14 +43,23 @@ void USpineBoneFollowerComponent::BeginPlay () { void USpineBoneFollowerComponent::TickComponent ( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) { Super::TickComponent( DeltaTime, TickType, ThisTickFunction ); - AActor* owner = GetOwner(); - if (Target && owner) { + if (Target) { USpineSkeletonComponent* skeleton = static_cast(Target->GetComponentByClass(USpineSkeletonComponent::StaticClass())); if (skeleton) { FTransform transform = skeleton->GetBoneWorldTransform(BoneName); - if (UsePosition) owner->SetActorLocation(transform.GetLocation()); - if (UseRotation) owner->SetActorRotation(transform.GetRotation()); - if (UseScale) owner->SetActorScale3D(transform.GetScale3D()); + if (UseComponentTransform) { + if (UsePosition) SetWorldLocation(transform.GetLocation()); + if (UseRotation) SetWorldRotation(transform.GetRotation()); + if (UseScale) SetWorldScale3D(transform.GetScale3D()); + } + else { + AActor* owner = GetOwner(); + if (owner) { + if (UsePosition) owner->SetActorLocation(transform.GetLocation()); + if (UseRotation) owner->SetActorRotation(transform.GetRotation()); + if (UseScale) owner->SetActorScale3D(transform.GetScale3D()); + } + } } } } diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineBoneDriverComponent.h b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineBoneDriverComponent.h index 24e98cbf2a..5f8db0d548 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineBoneDriverComponent.h +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineBoneDriverComponent.h @@ -30,13 +30,13 @@ #pragma once -#include "Components/ActorComponent.h" +#include "Components/SceneComponent.h" #include "SpineBoneDriverComponent.generated.h" class USpineSkeletonComponent; UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) -class SPINEPLUGIN_API USpineBoneDriverComponent : public UActorComponent { +class SPINEPLUGIN_API USpineBoneDriverComponent : public USceneComponent { GENERATED_BODY() public: @@ -46,6 +46,10 @@ class SPINEPLUGIN_API USpineBoneDriverComponent : public UActorComponent { UPROPERTY(EditAnywhere, BlueprintReadWrite) FString BoneName; + //Uses just this component when set to true. Updates owning actor otherwise. + UPROPERTY(EditAnywhere, BlueprintReadWrite) + bool UseComponentTransform = false; + UPROPERTY(EditAnywhere, BlueprintReadWrite) bool UsePosition = true; diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineBoneFollowerComponent.h b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineBoneFollowerComponent.h index d0e85e9c28..9ee387b8f7 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineBoneFollowerComponent.h +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineBoneFollowerComponent.h @@ -35,7 +35,7 @@ UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) -class SPINEPLUGIN_API USpineBoneFollowerComponent : public UActorComponent { +class SPINEPLUGIN_API USpineBoneFollowerComponent : public USceneComponent { GENERATED_BODY() public: @@ -45,6 +45,10 @@ class SPINEPLUGIN_API USpineBoneFollowerComponent : public UActorComponent { UPROPERTY(EditAnywhere, BlueprintReadWrite) FString BoneName; + //Updates just this component when set to true. Updates owning actor otherwise. + UPROPERTY(EditAnywhere, BlueprintReadWrite) + bool UseComponentTransform = false; + UPROPERTY(EditAnywhere, BlueprintReadWrite) bool UsePosition = true;