void UAnimSingleNodeInstance::SetAnimationAsset(class UAnimationAsset* NewAsset,bool bIsLooping,float InPlayRate) { if (NewAsset != CurrentAsset) { CurrentAsset = NewAsset; } if (USkeletalMeshComponent * MeshComponent = GetSkelMeshComponent()) { if (MeshComponent->SkeletalMesh == NULL) { // if it does not have SkeletalMesh, we nullify it CurrentAsset = NULL; } else if (CurrentAsset != NULL) { // if we have an asset, make sure their skeleton matches, otherwise, null it if (CurrentSkeleton != CurrentAsset->GetSkeleton()) { // clear asset since we do not have matching skeleton CurrentAsset = NULL; } } } bLooping = bIsLooping; PlayRate = InPlayRate; CurrentTime = 0.f; BlendSpaceInput = FVector::ZeroVector; #if WITH_EDITORONLY_DATA PreviewPoseCurrentTime = 0.0f; #endif UAnimMontage* Montage = Cast<UAnimMontage>(CurrentAsset); if ( Montage!=NULL ) { ReinitializeSlotNodes(); if ( Montage->SlotAnimTracks.Num() > 0 ) { RegisterSlotNodeWithAnimInstance(Montage->SlotAnimTracks[0].SlotName); } RestartMontage( Montage ); SetPlaying(bPlaying); } else { // otherwise stop all montages StopAllMontages(0.25f); UBlendSpaceBase * BlendSpace = Cast<UBlendSpaceBase>(CurrentAsset); if(BlendSpace) { BlendSpace->InitializeFilter(&BlendFilter); } } }
void UAnimSingleNodeInstance::SetAnimationAsset(class UAnimationAsset* NewAsset,bool bIsLooping,float InPlayRate) { if (NewAsset != CurrentAsset) { CurrentAsset = NewAsset; } if (USkeletalMeshComponent * MeshComponent = GetSkelMeshComponent()) { if (MeshComponent->SkeletalMesh == NULL) { // if it does not have SkeletalMesh, we nullify it CurrentAsset = NULL; } else if (CurrentAsset != NULL) { // if we have an asset, make sure their skeleton matches, otherwise, null it if (CurrentSkeleton != CurrentAsset->GetSkeleton()) { // clear asset since we do not have matching skeleton CurrentAsset = NULL; } } } bLooping = bIsLooping; PlayRate = InPlayRate; CurrentTime = 0.f; #if WITH_EDITORONLY_DATA PreviewPoseCurrentTime = 0.0f; #endif UAnimMontage* Montage = Cast<UAnimMontage>(CurrentAsset); if ( Montage!=NULL ) { ActiveSlotWeights.Empty(); if ( Montage->SlotAnimTracks.Num() > 0 ) { RegisterSlotNode(Montage->SlotAnimTracks[0].SlotName); } RestartMontage( Montage ); } else { // otherwise stop all montages StopAllMontages(0.25f); } }
void UAnimSingleNodeInstance::SetPlaying(bool bIsPlaying) { bPlaying = bIsPlaying; if (FAnimMontageInstance* CurMontageInstance = GetActiveMontageInstance()) { CurMontageInstance->bPlaying = bIsPlaying; } else if (bPlaying) { UAnimMontage* Montage = Cast<UAnimMontage>(CurrentAsset); if (Montage) { RestartMontage(Montage); } } }