More control over playing a montage
This commit is contained in:
		
							parent
							
								
									28963c78e9
								
							
						
					
					
						commit
						d9ec367b82
					
				@ -63,15 +63,8 @@ bool UFFState::CanTransition(const FFFStateContext& InStateContext)
 | 
			
		||||
 | 
			
		||||
void UFFState::Enter(const FFFStateContext& InStateContext)
 | 
			
		||||
{
 | 
			
		||||
    if(InStateContext.Avatar)
 | 
			
		||||
    {
 | 
			
		||||
        USkeletalMeshComponent* SMC = InStateContext.Avatar->GetComponentByClass<USkeletalMeshComponent>();
 | 
			
		||||
        if(SMC && MontageToPlay)
 | 
			
		||||
        {
 | 
			
		||||
            SMC->GetAnimInstance()->Montage_Play(MontageToPlay);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    PlayMontage(InStateContext);
 | 
			
		||||
    
 | 
			
		||||
    OnEnter(InStateContext);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -180,6 +173,11 @@ void UFFState::RegisterInputHandler(const FFFInputSequence& InRequiredSequence,
 | 
			
		||||
    InputHandlers.Add(TempHandler);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UFFState::PlayMontage(const FFFStateContext& InStateContext)
 | 
			
		||||
{
 | 
			
		||||
    OnPlayMontage(InStateContext);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void UFFState::OnInit_Implementation(const FFFStateContext& InStateContext)
 | 
			
		||||
{
 | 
			
		||||
@ -192,6 +190,19 @@ bool UFFState::OnCanTransition_Implementation(const FFFStateContext& InStateCont
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void UFFState::OnPlayMontage_Implementation(const FFFStateContext& InStateContext)
 | 
			
		||||
{
 | 
			
		||||
    if(InStateContext.Avatar)
 | 
			
		||||
    {
 | 
			
		||||
        USkeletalMeshComponent* SMC = InStateContext.Avatar->GetComponentByClass<USkeletalMeshComponent>();
 | 
			
		||||
        if(SMC && MontageToPlay)
 | 
			
		||||
        {
 | 
			
		||||
            SMC->GetAnimInstance()->Montage_Play(MontageToPlay);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
UWorld* UFFState::GetWorld() const
 | 
			
		||||
{
 | 
			
		||||
	UFFStateMachineComponent* SMC = Cast<UFFStateMachineComponent>(GetOuter());
 | 
			
		||||
 | 
			
		||||
@ -228,6 +228,16 @@ public:
 | 
			
		||||
	UFUNCTION(BlueprintImplementableEvent, Category="UFF|State|Events")
 | 
			
		||||
	void OnUpdate(float OneFrame, const FFFStateContext& InStateContext);
 | 
			
		||||
 | 
			
		||||
	UFUNCTION(BlueprintCallable, Category="UFF|State|Animations")
 | 
			
		||||
	void PlayMontage(const FFFStateContext& InStateContext);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     *	Blueprint hook for overriding the logic for when a anim montage plays at the start of a state
 | 
			
		||||
     *	@param InStateContext 
 | 
			
		||||
     */
 | 
			
		||||
    UFUNCTION(BlueprintNativeEvent, Category="UFF|State|Events")
 | 
			
		||||
	void OnPlayMontage(const FFFStateContext& InStateContext);
 | 
			
		||||
 | 
			
		||||
	// TODO: document
 | 
			
		||||
	UFUNCTION(BlueprintImplementableEvent, Category="UFF|State|Events")
 | 
			
		||||
	void OnLanded(const FHitResult& Hit, const FFFStateContext& InStateContext);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user