How create object from class?

Hello !

I have 2 blueprints: house and window. How create a new object “window” (using it’s blueprint) inside the blueprint “house” ? I try to use node “Construct object from class”, but I see nothing in my scene:

The variable Window_BP is not assigned after this node.


How create it and how it use, for example set location ?

In order to spawn it and place it in the world the object has to be an actor. You have to use Spawn Actor From Class.

To be able to do this you also have to make the object a child of Actor.

Hope this helps.

Thank you for answer!
But Spawn Actor node exists only in Event Graph. I need create window in the Construction Script in the BP editor. I created a building and I want create windows for it. Can I do it in the blueprint editor?

Is there a reason for why you dont simply attach the objects in the blueprint viewport? If you need to change location or spawn more depending on the size you might want to have a look at the BP_Fence inside the Content Examples. Inside the level Blueprints_Advanced the BP_Fence blueprint is placed so you can look at it for reference.

In short, what it does is adding static mesh components and setting the static mesh. You should be able to do the same with add actor component then set the actor after using spawn object from class. I have not tested this, but I do not see why it should not work.

You cannot create new objects within BP construction scripts;
It’s a very old known limitation.

So what is the fence blueprint using? It is adding static mesh components and then setting a static mesh for each. Does it not have to create a new mesh instance for every x centimeters?

I want to use a lot of windows: with various type of frame (various quantity of frame elements; with thin metal or usual wood frame, etc.). All these type of windows I can create by using ONE blueprint. And It’s seems good idea use this blueprint object inside other blueprint to creation a house.

If it’s impossible, I need to create all these window-objects as separately Static Mesh objects. It’s not really flexible and mobile way to create objects.

You have to make every material and make every mesh. If the mesh looks different you have to make it. You can mix and match as you like. However, you can not generate holes in a mesh that it does not have. So if your house only allows for 3 windows you can only add 3 windows. The size has to match as well. You can change what window mesh you use and what material top apply, but that is it.