GameObject.Find equivalent for UE4?

Hello…

In Unity there is a way to find an object in the world, using GameObject.Find …
What is the equivalent for Unreal Engine ?..

I can use UPROPERTY(EditEverywhere) macro to attach the object I want, but I want to define a var for this object on BeginPlay() method this time.

Thanks.

1 Like

Gameplaystatics helper class is easy to use:

2 Likes

It is unbelievable how simple it is in Unity and there is no such thing via Blueprinte in Unreal. I haven’t found it yet.

GameObject.Find, GetComponent<>(), Resources.Load is so useful. If someone know a version of this tools in Unreal via Blueprint tell me please.

For Find, you should not be using it even on Unity, but you can implement your own version of it in Unreal if you want to, this page have very good examples: https://docs.unrealengine.com/en-US/…nts/index.html

GetComponent<> is GetComponentByClass: https://docs.unrealengine.com/en-US/…***/index.html

For Resources.Load there is a LoadAsset function but I never used so not sure if it is actually an equivalent. A quick google search brought me a couple of different solutions for that.

Much of Unity is built around doing things you can probably design better for.

If you can’t find a reference to the object that you’re looking for, via any method other than searching All Objects, then… how did you get in that position?

What is the specific situation you’re trying to get through?

Where does the object come from? How do you filter all possible objects to the one object you want?
Are you sure there’s only one instance of the particular class? Or does it have a unique name?
You can easily get all objects of a particular class from blueprint, and then filter down to a particular name if you want.
Do this for Actor and you have a good approximation of what you’re looking for. It’ll perform poorly, of course – it does in Unity, too.
Another option to look at is gameplay tags. It depends on exactly what goal it is you’re trying to achieve.

在虚幻引擎中,关卡中的Actor名称似乎是自动生成的,不允许有重复的名称存在。没有像Unity一样的层级关系,Actor与GameObject只是看上去一致,事实上存在很大的差异。