참고 문서
이 게시글의 댓글을 보고 문제를 고칠 수 있었다.
jollymonsterstudio.com/2018/12/10/unreal-engine-c-fundamentals-uanimnotify-uanimnotifystate/
Unreal Engine C++ Fundamentals – UAnimNotify & UAnimNotifyState
Hey guys, Today we are going to continue exploring Unreal Engine C++ Fundamentals before we get back to our Player Character series by taking a look at Anim Notify and Anim Notify States. You can find the GitHub project for this video in the usual location
jollymonsterstudio.com
상황
AnimNotify 클래스를 상속받아서 만든 클래스에서 Notify 함수를 오버라이딩했다.
디버깅 함수를 사용하다가 GetWorld()를 사용하게 되었다.
void UAnimNotify_CheckAttack::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation)
{
Super::Notify(MeshComp, Animation);
FVector Pos = MeshComp->GetComponentLocation();
UKismetSystemLibrary::DrawDebugSphere(
GetWorld(), // 여기에 GetWorld()를 사용했었음.
Pos,
150.0f,
12,
FLinearColor::White,
3.0f,
0.0f
);
}
컴파일은 잘 된다.
게임 내에서 이 함수가 실행되면, 에러 메세지가 나오면서 DebugSphere가 제대로 찍히지 않았다.
에러 메세지를 읽어보니 GetWorld()가 Null 값을 반환하나보다.

LogScript: Warning: Script Msg: A null object was passed as a world context object to UEngine::GetWorldFromContextObject().
해결
GetWorld()가 아니라 MeshComp->GetWorld()로 바꿔주면 된다.
void UAnimNotify_CheckAttack::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation)
{
Super::Notify(MeshComp, Animation);
FVector Pos = MeshComp->GetComponentLocation();
UKismetSystemLibrary::DrawDebugSphere(
MeshComp->GetWorld(), // MeshComp의 GetWorld()로 바꿔줌.
Pos,
150.0f,
12,
FLinearColor::White,
3.0f,
0.0f
);
}
원인
구글링을 하면서 원인을 쓴 글을 본 거 같은데, 다시 그 글을 찾으려하니 모르겠다.
Notify 자체는 GetWorld를 해도 자기가 어느 공간에 있는지 몰라서 Null을 반환한다.
MeshComp의 GetWorld는 MeshComp가 존재하는 공간이라서 GetWorld를 하면 값을 제대로 반환한다.
'기타 > Unreal' 카테고리의 다른 글
[Unreal Error] LogUObjectBase: Warning: NULL object 해결하기 (0) | 2021.05.03 |
---|---|
[Unreal Error] Destroy()가 false를 반환하는 경우 (0) | 2021.04.29 |
[Unreal C++] 액터 오브젝트에 컴포넌트 추가하기 (0) | 2021.04.20 |
[Unreal C++] IWYU 알아보기 (Include-What-You-Use) (0) | 2021.04.15 |
[Unreal BP] AI MoveTo 사용하기 (0) | 2021.04.14 |
참고 문서
이 게시글의 댓글을 보고 문제를 고칠 수 있었다.
jollymonsterstudio.com/2018/12/10/unreal-engine-c-fundamentals-uanimnotify-uanimnotifystate/
Unreal Engine C++ Fundamentals – UAnimNotify & UAnimNotifyState
Hey guys, Today we are going to continue exploring Unreal Engine C++ Fundamentals before we get back to our Player Character series by taking a look at Anim Notify and Anim Notify States. You can find the GitHub project for this video in the usual location
jollymonsterstudio.com
상황
AnimNotify 클래스를 상속받아서 만든 클래스에서 Notify 함수를 오버라이딩했다.
디버깅 함수를 사용하다가 GetWorld()를 사용하게 되었다.
void UAnimNotify_CheckAttack::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation)
{
Super::Notify(MeshComp, Animation);
FVector Pos = MeshComp->GetComponentLocation();
UKismetSystemLibrary::DrawDebugSphere(
GetWorld(), // 여기에 GetWorld()를 사용했었음.
Pos,
150.0f,
12,
FLinearColor::White,
3.0f,
0.0f
);
}
컴파일은 잘 된다.
게임 내에서 이 함수가 실행되면, 에러 메세지가 나오면서 DebugSphere가 제대로 찍히지 않았다.
에러 메세지를 읽어보니 GetWorld()가 Null 값을 반환하나보다.

LogScript: Warning: Script Msg: A null object was passed as a world context object to UEngine::GetWorldFromContextObject().
해결
GetWorld()가 아니라 MeshComp->GetWorld()로 바꿔주면 된다.
void UAnimNotify_CheckAttack::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation)
{
Super::Notify(MeshComp, Animation);
FVector Pos = MeshComp->GetComponentLocation();
UKismetSystemLibrary::DrawDebugSphere(
MeshComp->GetWorld(), // MeshComp의 GetWorld()로 바꿔줌.
Pos,
150.0f,
12,
FLinearColor::White,
3.0f,
0.0f
);
}
원인
구글링을 하면서 원인을 쓴 글을 본 거 같은데, 다시 그 글을 찾으려하니 모르겠다.
Notify 자체는 GetWorld를 해도 자기가 어느 공간에 있는지 몰라서 Null을 반환한다.
MeshComp의 GetWorld는 MeshComp가 존재하는 공간이라서 GetWorld를 하면 값을 제대로 반환한다.
'기타 > Unreal' 카테고리의 다른 글
[Unreal Error] LogUObjectBase: Warning: NULL object 해결하기 (0) | 2021.05.03 |
---|---|
[Unreal Error] Destroy()가 false를 반환하는 경우 (0) | 2021.04.29 |
[Unreal C++] 액터 오브젝트에 컴포넌트 추가하기 (0) | 2021.04.20 |
[Unreal C++] IWYU 알아보기 (Include-What-You-Use) (0) | 2021.04.15 |
[Unreal BP] AI MoveTo 사용하기 (0) | 2021.04.14 |