Why 'Spawn Actor From Class' node returns actor reference when get class from other node?

Look.

To set material of actor, it needs actor’s primitive component. No problem is in here. BUT,
When I connect Class pin in Set Building to Spawn to Class pin in SpawnActor Node, Return pin doesn’t give reference of actor Floor. So return pin and primitive component pin are disconnected. like this.

And I wanna know why.

Hi

Fast answer, actor reference is for whole actor, not for actor mesh. You need to get mesh node from referenced actor to set it material. So get node from Floor (ref.) Get Mesh (can have different name, just this is your mesh in floor actor), then set material.

It wont connect the return pin because the variable class isnt a set value until runtime. Ao the varibke could in theiry be any class and not all classes have the floor component

Thanks. but I wanna put spawn actor and set material nodes to function. And get class from event graph. And also I wanna set reference of Floor to variable and set meterial from that variable. how can I do those things?

Thanks. but I wanna put spawn actor and set material nodes to function. And get class from event graph. And also I wanna set reference of Floor to variable and set meterial from that variable. how can I do those things?

ps. “Ao the varibke could in theiry…” Is this sentence typo? or abbreviation?

The reason why this happens is because the types of class references aren’t the same. Your BuildingToSpawn might be of type “Actor Class Reference”, or something similar, which is a reference to the class higher up in the class hierarchy. Your Floor Class is derived from Actor, but if you get an Actor Class reference, you can only get components from the Actor class.

And the class “Actor” does not have a floor mesh by default, unlike to your own class, “Floor”.

Meanwhile if you select Floor class from the drop-down of the spawn actor, you will always assign a “Floor Class Reference”.

So, either change the variable type of the class variable to “Floor Class Reference”, either by changing the type of the Set variable before the SpawnActor -node, or use the drop-down in SpawnActor instead. If you want to keep on using “Actor Class Reference”, you need to cast before you can access the floor mesh.

With function is a little problem, because as I see, you have to do cast to FloorBP after spawn to get floor mesh. I will do little test, now I’m busy.

that was a combination of big hands on a small phone and not checking what i wrote closely.

Ok, I see only dynamic solution works for function, is set mesh and material, because this is correct way. Here Function screen:

here is function call

and here function inputs:

Actor Floor is empty actor, mesh will be created and material set:

You can use it in any other procedural actor, not only floor ofc. Sample is jus start, not production solution.

Lol bootyful.

So… am I have to keep mesh in BP that I am fixing? Not floor BP? If it’s true, I better make floor as component not other BP. That seems not good

You really helps me a lot. Thx. I will try it tommorow. Im wondering to people like U. People like u helps others passionately with no resons. Cool.

It’s up to you. If you need for single blueprint and only change floor material, you must use cast to floor blueprint then get floor mesh. My solution is universal, no idea usable or not, just working. Here many ways to achieve desired effect, but it must follow some rules.