How do I create actors during runtime?

as i understand actors in unreal engine just like gameObject in unity3d
so in unity i can create gameobject, add mesh renderer, mesh filter and assign mesh. there it is. all with few lines of code.

and i just can’t find closest analogue in unreal engine.

90% information in google about blueprints and how to use them.

all i found that i need to write and setup separate class for each actor i need to spawn.

question is how to create, setup and spawn actor on the fly ?

You spawn an actor with the SpawnActor function found in UWorld. Here is an example:

AMyActorSubClass* MyActor= GetWorld()->SpawnActor<AMyActorSubClass>(AMyActorSubClass::StaticClass());

There are a bunch of other parameters to pass into SpawnActor, like position and rotation and such. Look at them all here: UWorld::SpawnActor | Unreal Engine Documentation

as i understand its only process of instantiation. but do i really need to write separate class for each actor ? or there is a way to do something like this

AActor* newActor = new AActor();

attach something to newActor

then instantiate it like you wrote.

As far as I know (someone can confirm this) you have to create a subclass. Keep in mind Unreal is not in any way like Unity, it’s development paradigms are very different. Even if you could spawn an AActor it would do literally nothing, and you would have to create a subclass anyway. I’ve never once even tried to do this myself.

To what end do you want to spawn an AActor?

In Unreal Engine 4.17 one can simply add a Spawn Actor ftom Class node and a Make Transform node inside a visual script that runs when you need this to happen.