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.
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.
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.