8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Unreal Engine 4メモ:Worldを取得する

Last updated at Posted at 2018-03-06

#GetWorldメソッドが無いオブジェクトでも取得したい
GetWorldメソッドを持たないオブジェクトは下記で取得可能ですが受け渡すObject引数は何でも良いのでしょうか?
world contextでなければならないとドキュメントには書いてあります。

Sample.cpp
UWorld * World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);

#world contextとは
world contextとはずばりワールドに配置されたオブジェクトです。Unreal Engineで使用するインスタンスは大きくオブジェクトとアクタの2種類に分けられ、特にワールドに配置するものを「アクタ」と呼んでいます。
つまり、world contextとは「アクタ」の事です。

さて、GetWorldを持っているオブジェクトってどんなだっけ?というとやはり「アクタ」なオブジェクトの事です。
つまりワールドに配置しているオブジェクトだからワールドの情報を取れるということですね。結局のところアクタが無ければワールド情報は取れません。

#参照
UEngine::GetWorldFromContextObjectChecked
UE4 ANSWER HUB / Timer crashes in Blueprint classes inherited from Object

8
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?