UCLASS()
class OCTOADVENTURE_API UAnimNotify_roll : public UAnimNotify
{
GENERATED_BODY()
public:
UAnimNotify_roll();
public:
virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override;
};
이런식으로 animnotify를 c++로 구현중에 있었다.
구르기 중 처리할게 있어서 구현 중이였는데 notify내부에서 performdash 부분이
실행이 안되었다.
void UAnimNotify_roll::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference)
{
Super::Notify(MeshComp, Animation, EventReference);
if (UWorld* world =GetWorld())
{
APlayerController* PlayerController = world->GetFirstPlayerController();
if (PlayerController)
{
AOctoPlayerController* OctoPlayerController = Cast<AOctoPlayerController>(PlayerController);
if (OctoPlayerController)
{
// OctoPlayerController의 함수 호출
OctoPlayerController->PerformDash();
}
}
else
ensure(false);
}
else
{
ensure(false);
}
}
대충 이렇게 playercontroller의 PerformDash함수를 호출하는 notify인데
계속 안되서 찾아보던 중 else ensure(false)로 떡칠하고 나서야
엄한 곳을 보고있다는걸 꺠달았다.
Animnotify에서는 GetWorld()를 못한다.
따라서 인자로들어온 MeshComp->GetWorld()을 호출해서 성공했다..