Download

Transform of a Component added via c++ does not be auto keyed in sequencer. How can i fix it?

As i mentioned in the title, i tried to add a component via c++ and also tried to control it in sequence.

this is the code how i added some component to the actor.

if (UActorComponent* BoneDriverComp = Owner->AddComponentByClass(USpineRigBoneDriverComponent::StaticClass(), false, FTransform(), false)) {
    if (USpineRigBoneDriverComponent* Casted = Cast<USpineRigBoneDriverComponent>(BoneDriverComp)) {

	FTransform Transform = Skeletion->GetBoneWorldTransform(TCHAR_TO_UTF8(*Name.ToString()));
	FAttachmentTransformRules Rule = FAttachmentTransformRules::KeepWorldTransform;

	Casted->Rename(*CompName.ToString(),this);

	Transform.SetScale3D(FVector(0.15, 0.3, 0.15));
	Casted->SetWorldTransform(Transform);
	Casted->BoneName = Name.ToString();

								
	Casted->AttachToComponent(this, Rule);
	Owner->AddInstanceComponent(BoneDriverComp);
	Owner->AddOwnedComponent(BoneDriverComp);

	RigBoneDrivers.Add(Name, Casted);
    }
}

Those component under the component ‘BongRig’ are the component that added via that code.

comp

so now i tried to modify the transform of each component with Auto-Key system, but for those components add via c++ seems doesn’t recorded properly by Auto-Key marking.

How can i fix this? i think the way i added the component to the actor is the cause… but i can’t find proper solution for this…

It would be great if you share any help for me… Thank you

i somehow find a way to handle this.

void GetActorAndSceneComponentFromObject( UObject* Object, AActor*& OutActor, USceneComponent*& OutSceneComponent )
{
	OutActor = Cast<AActor>( Object );
	if ( OutActor != nullptr && OutActor->GetRootComponent() )
	{
		OutSceneComponent = OutActor->GetRootComponent();
	}
	else
	{
		// If the object wasn't an actor attempt to get it directly as a scene component and then get the actor from there.
		OutSceneComponent = Cast<USceneComponent>( Object );
		if ( OutSceneComponent != nullptr )
		{
			OutActor = Cast<AActor>( OutSceneComponent->GetOuter() );
		}
	}
}

i found the function that track down the changes on component transform (F3DTransformTrackEditor::OnTransformChanged) , and i figured out that if the component does not have an actor as its outer , than auto keying on the transform track will not work.

I handled this problem by creating component with NewObject Function with actor outer in.