void UBaseEnemyAnimInstance::PlayAttackAnimation()
{
	if (AttackMontage && !Montage_IsPlaying(AttackMontage))
	{
		//GLog->Log("Playing attack montage");
		Montage_Play(AttackMontage);
	}
}
void UBaseEnemyAnimInstance::PlayGetHitAnimation()
{
	if (GetHitMontage && !Montage_IsPlaying(GetHitMontage))
	{
		//GLog->Log("Playing get hit montage");
		Montage_Play(GetHitMontage);
		//GLog->Log("Epaiksa montage");
	}
}
Ejemplo n.º 3
0
float UAnimInstance::PlaySlotAnimation(UAnimSequenceBase* Asset, FName SlotNodeName, float BlendInTime, float BlendOutTime, float InPlayRate)
{
	// create temporary montage and play
	bool bValidAsset = Asset && !Asset->IsA(UAnimMontage::StaticClass());
	if (!bValidAsset)
	{
		// user warning
		UE_LOG(LogAnimation, Warning, TEXT("Invalid Asset. If Montage, use Montage_Play"));
		return 0.f;
	}

	if (SlotNodeName == NAME_None)
	{
		// user warning
		UE_LOG(LogAnimation, Warning, TEXT("SlotNode Name is required. Make sure to add Slot Node in your anim graph and name it."));
		return 0.f;
	}

	USkeleton * AssetSkeleton = Asset->GetSkeleton();
	if (!CurrentSkeleton->IsCompatible(AssetSkeleton))
	{
		UE_LOG(LogAnimation, Warning, TEXT("The Skeleton isn't compatible"));
		return 0.f;
	}

	// now play
	UAnimMontage * NewMontage = NewObject<UAnimMontage>();
	NewMontage->SetSkeleton(AssetSkeleton);

	// add new track
	FSlotAnimationTrack NewTrack;
	NewTrack.SlotName = SlotNodeName;
	FAnimSegment NewSegment;
	NewSegment.AnimReference = Asset;
	NewSegment.AnimStartTime = 0.f;
	NewSegment.AnimEndTime = Asset->SequenceLength;
	NewSegment.AnimPlayRate = 1.f;
	NewSegment.StartPos = 0.f;
	NewMontage->SequenceLength = Asset->SequenceLength;
	NewTrack.AnimTrack.AnimSegments.Add(NewSegment);
		
	FCompositeSection NewSection;
	NewSection.SectionName = TEXT("Default");
	NewSection.StartTime = 0.f;

	// add new section
	NewMontage->CompositeSections.Add(NewSection);
	NewMontage->BlendInTime = BlendInTime;
	NewMontage->BlendOutTime = BlendOutTime;
	NewMontage->SlotAnimTracks.Add(NewTrack);

	return Montage_Play(NewMontage, InPlayRate);
}
void UAnimSingleNodeInstance::RestartMontage(UAnimMontage * Montage, FName FromSection)
{
	if( Montage == CurrentAsset )
	{
		Montage_Play(Montage, PlayRate);
		if( FromSection != NAME_None )
		{
			Montage_JumpToSection(FromSection);
		}
		SetMontageLoop(Montage, bLooping, FromSection);
	}
}
Ejemplo n.º 5
0
void UAnimPreviewInstance::MontagePreview_PreviewAllSections()
{
	UAnimMontage* Montage = Cast<UAnimMontage>(CurrentAsset);
	if (Montage && Montage->SequenceLength > 0.f)
	{
		MontagePreviewType = EMPT_AllSections;
		Montage_Play(Montage, PlayRate);
		MontagePreview_SetLoopAllSections(bLooping);
		MontagePreview_JumpToPreviewStart();
		MontagePreview_RemoveBlendOut();
		bPlaying = true;
	}
}
Ejemplo n.º 6
0
void UAnimPreviewInstance::RestartMontage(UAnimMontage* Montage, FName FromSection)
{
	if (Montage == CurrentAsset)
	{
		MontagePreviewType = EMPT_Normal;
		Montage_Play(Montage, PlayRate);
		if (FromSection != NAME_None)
		{
			Montage_JumpToSection(FromSection);
		}
		MontagePreview_SetLoopNormal(bLooping, Montage->GetSectionIndex(FromSection));
	}
}
Ejemplo n.º 7
0
void AFournoidWeapon::PlayFireAnimation()
{
	if ( FireAnimation )
	{
		auto AnimInstance = Mesh1P->GetAnimInstance();
		if ( AnimInstance )
		{
			AnimInstance->Montage_Play(FireAnimation, 1.f);
		}
	}
	
	if ( FireEmitter )
	{
		UGameplayStatics::SpawnEmitterAtLocation(this, FireEmitter, GetMuzzleLocation());
	}
}
Ejemplo n.º 8
0
void UAnimPreviewInstance::MontagePreview_PreviewNormal(int32 FromSectionIdx)
{
	if (UAnimMontage* Montage = Cast<UAnimMontage>(CurrentAsset))
	{
		int32 PreviewFromSection = FromSectionIdx;
		if (FromSectionIdx != INDEX_NONE)
		{
			MontagePreviewStartSectionIdx = MontagePreview_FindFirstSectionAsInMontage(FromSectionIdx);
		}
		else
		{
			FromSectionIdx = MontagePreviewStartSectionIdx;
			PreviewFromSection = MontagePreviewStartSectionIdx;
		}
		MontagePreviewType = EMPT_Normal;
		Montage_Play(Montage, PlayRate);
		MontagePreview_SetLoopNormal(bLooping, FromSectionIdx);
		Montage_JumpToSection(Montage->GetSectionName(PreviewFromSection));
		MontagePreview_RemoveBlendOut();
		bPlaying = true;
	}
}