How can I get the actor class from a variable?

Hello. I want to change the material of an actor class in blueprint when the ui button is pressed. I can do it when I import the Actor class manually, but when I call it from a variable, it gives an error “actor object reference is not compatible with primitive component object” when connecting it to the set material node.



This is how I transfer the object I selected with the mouse to the variable.

How can I resolve this error?

get the static/skeletal mesh from the actor.

The Actor reference is pointing to the Actor object(e.g. the entire blueprint). But to set the material, you need to get just one component of that actor.
Which component? The component that is responsible for rendering the actor. Usually that is going to be either a skeletal or static mesh component.

So from the actor reference, search for Get Static/Skeletal mesh. Once you find that, then you can set the material.

To understand what type a node is outputting or requiring for input, hover your cursor over the input/output dot and a tooltip will describe what sort of reference is required.

In addition to the previous answer:
You can take the first primitive component (if it exists) and assign a material to it. The approach will work if the actor has only one such component.

My Products