How can I assign a C++ variable to Actor?

Hi,

I’m using UE4.1 / VS2013Ultimate.

I would like to know a good way to retrieve an Actor from the scene to the C++ code.

I declared the variable this way

UPROPERTY(EditAnywhere, BlueprintReadWrite)
 AStaticMeshActor* CubeUnit;

Does the engine have a function to retrieve an actor from the scene ?

Or should I do this in Blueprint (and if yes, how) ?

Thanks!

#Object and Actor Iterators

You can use the Object Iterator and the Actor Iterator to find Actors or objects that are in the scene!

I recommend using Actor Iterator if looking for an actor while playing the game in the Editor / PIE

#Wiki Tutorial

A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine ForumsObject%26_Actor_Iterators,_Optional_Class_Scope_For_Faster_Search

#Checking Actor Names

If you name your actor in your scene something you can check the actor’s name when using the Actor Iterator

Actor->GetName()

:slight_smile:

Rama

Thanks a lot Rama, that worked :slight_smile: !