How do I change the Skeletal Mesh Component for PlayMontageAndWait?

Hi,

Is it possible to change the Skeletal Mesh Component to PlayMontageAndWait as in PlayMontage?

I have 3 Skeletal Mesh Component in my character and the player can decide in the game which one to use. With PlayMontage the change works well. But with PlayMontageAnWait the first mesh is always the target.

1 Like

Hi @Bibberjack, did you find any solution?

In case anyone is looking, there is no blueprint solution. But you can override InitAbilityActorInfo in UAbilitySystemComponent. In this just call the Super method and then replace the reference AbilityActorInfo->SkeletalMeshComponent.

Example Header:

#pragma once

#include "CoreMinimal.h"
#include "AbilitySystemComponent.h"
#include "GothGirlAbilitySystemComponent.generated.h"


UCLASS(ClassGroup="GothGirl", meta=(BlueprintSpawnableComponent))
class GOTHGIRL_API UGothGirlAbilitySystemComponent : public UAbilitySystemComponent
{
	GENERATED_BODY()

protected:
	virtual void InitAbilityActorInfo(AActor* InOwnerActor, AActor* InAvatarActor) override;

};

Example CPP:

#include "GothGirlAbilitySystemComponent.h"
#include "AI/SecretAgentManCharacter.h"

void UGothGirlAbilitySystemComponent::InitAbilityActorInfo(AActor* InOwnerActor, AActor* InAvatarActor)
{
	Super::InitAbilityActorInfo(InOwnerActor, InAvatarActor);

	if (ASecretAgentManCharacter* Agent = Cast<ASecretAgentManCharacter>(AbilityActorInfo->OwnerActor.Get()))
		if (IsValid(Agent->GetNPCMesh()->GetSkeletalMeshAsset())) AbilityActorInfo->SkeletalMeshComponent = Agent->GetNPCMesh();
}

Warning there is a UAbilitySystemComponent::RefreshAbilityActorInfo() which is not overridable and can be called by blueprints. This will reset AbilityActorInfo->SkeletalMeshComponent. Just don’t use it.