/*********************************************************** start attack script ***********************************************************/ void NPCHandler::StartAttackScript() { #ifdef _DEBUG_NPC_ filecheck<<SynchronizedTimeHandler::GetTimeString()<<" "<<"start atack script"<<std::endl; #endif if(_fightscriptrunning) StopAttackScript(); //stop old script // start the script if(m_attackfunctionname != "" && m_scripthandler) { _fightscriptrunning = true; if(_weaponanimatstart) { if(CanPlayAnimation("PrepareWeapon")) { UpdateActorAnimation("PrepareWeapon", false, false); _weaponanimating = true; } } } //m_scripthandler->StartScript(m_attackfunctionname, GetId(), false, m_launchedattackscript); }
void FMovieSceneSkeletalAnimationTrackInstance::PreviewSetAnimPosition(USkeletalMeshComponent* SkeletalMeshComponent, FName SlotName, int32 ChannelIndex, UAnimSequenceBase* InAnimSequence, float InPosition, bool bLooping, bool bFireNotifies, float DeltaTime, bool bPlaying, bool bResetDynamics) { if(CanPlayAnimation(SkeletalMeshComponent, InAnimSequence)) { UAnimMontage* Montage = FAnimMontageInstance::PreviewMatineeSetAnimPositionInner(SlotName, SkeletalMeshComponent, InAnimSequence, InPosition, bLooping, bFireNotifies, DeltaTime); // if we are not playing, make sure we dont continue (as skeletal meshes can still tick us onwards) UAnimInstance* AnimInst = SkeletalMeshComponent->GetAnimInstance(); UAnimSingleNodeInstance * SingleNodeInst = SkeletalMeshComponent->GetSingleNodeInstance(); if(SingleNodeInst) { SingleNodeInst->SetPlaying(bPlaying); } else if (AnimInst) { if(Montage) { if(bPlaying) { AnimInst->Montage_Resume(Montage); } else { AnimInst->Montage_Pause(Montage); } } if(bResetDynamics) { // make sure we reset any simulations AnimInst->ResetDynamics(); } } } }
/*********************************************************** play hurt animation ***********************************************************/ void NPCHandler::PlayHurt(int hurttype) { std::string hurtanimstring; // check if we can play animation - if not try smaller hurt for(; hurttype > 0; --hurttype) { if(hurttype == 3) { if(CanPlayAnimation("HurtBig")) { hurtanimstring = "HurtBig"; break; } } if(hurttype == 2) { if(CanPlayAnimation("HurtMedium")) { hurtanimstring = "HurtMedium"; break; } } if(hurttype == 1) { if(CanPlayAnimation("HurtSmall")) { hurtanimstring = "HurtSmall"; break; } } } if(hurtanimstring == "") ChangeState(_savedstate); // cant play hurt - go back to normal else UpdateActorAnimation(hurtanimstring, false, false); // update to hurt animation }
void FMovieSceneSkeletalAnimationTrackInstance::PreviewBeginAnimControl(USkeletalMeshComponent* SkeletalMeshComponent) { if (CanPlayAnimation(SkeletalMeshComponent)) { UAnimInstance* AnimInstance = SkeletalMeshComponent->GetAnimInstance(); if (!AnimInstance) { SkeletalMeshComponent->SetAnimationMode(EAnimationMode::Type::AnimationSingleNode); } } CurrentlyPlayingMontage = nullptr; }
void FMovieSceneSkeletalAnimationTrackInstance::SetAnimPosition(USkeletalMeshComponent* SkeletalMeshComponent, FName SlotName, int32 ChannelIndex, UAnimSequenceBase* InAnimSequence, float InPosition, bool bLooping, bool bFireNotifies) { if (CanPlayAnimation(SkeletalMeshComponent, InAnimSequence)) { UAnimMontage* Montage = FAnimMontageInstance::SetMatineeAnimPositionInner(SlotName, SkeletalMeshComponent, InAnimSequence, InPosition, bLooping); // Ensure the sequence is not stopped UAnimInstance* AnimInst = SkeletalMeshComponent->GetAnimInstance(); UAnimSingleNodeInstance* SingleNodeInst = SkeletalMeshComponent->GetSingleNodeInstance(); if(SingleNodeInst) { SingleNodeInst->SetPlaying(true); } else if (AnimInst && Montage) { AnimInst->Montage_Resume(Montage); } } }
void FMovieSceneSkeletalAnimationTrackInstance::PreviewFinishAnimControl(USkeletalMeshComponent* SkeletalMeshComponent) { if (CanPlayAnimation(SkeletalMeshComponent)) { // if in editor, reset the Animations, makes easier for artist to see them visually and align them // in game, we keep the last pose that matinee kept. If you'd like it to have animation, you'll need to have AnimTree or AnimGraph to handle correctly if (SkeletalMeshComponent->GetAnimationMode() == EAnimationMode::Type::AnimationBlueprint) { UAnimInstance* AnimInstance = SkeletalMeshComponent->GetAnimInstance(); if(AnimInstance) { AnimInstance->Montage_Stop(0.f); AnimInstance->UpdateAnimation(0.f, false); } } // Update space bases to reset it back to ref pose SkeletalMeshComponent->RefreshBoneTransforms(); SkeletalMeshComponent->RefreshSlaveComponents(); SkeletalMeshComponent->UpdateComponentToWorld(); } CurrentlyPlayingMontage = nullptr; }