How to cast a Blueprint

Hello,
I’m new to UE4 and Blueprints so I’m sorry in advance if the question is really obvious.
I was trying to convert this:

To this something like this:

I wanted the target to be the mesh of the blueprint and not the mesh of the character, however, I don’t know how to set it up so that it works.

Simply add a “self” node ( right click, type “self” ) and link it to the “object” pin of the cast node

i’m assuming the object it’s called on a base class of “BP_VaseOk”, if a situation can happens this code is run on something not of the good class you should add an ‘if’ on the success pin

if the blueprint the code is into, simply link the self node to the Static mesh composent node ( no cast required )
( in fact in that case, you don’t even need a “self” node, simply right click and type “GetStaticMesh” and you should find the correct node )

Thank you for your help.
I tried your first advice and this came up:

And then if I only link the target to the static mesh this comes up:

This code is inside a widget that should direct the information of the color picker to the mesh (the vase Blueprint) that I’m trying to modify.

This falls into a category of problems I like to call the “wanna access this object thing from this other object thing” category.

Accessing specific objects from other objects is at the heart of Object-Oriented Programming, which is fundamental to how blueprints (and the whole of UE4) operates.

Anyway, wherever you’re running your blueprint script, you need a reliable way to access the target actor (your BP_Vase actor) whose color you want to update. There are multiple ways to do this, and it’s up to you to decide which is best for your use case.

Here’s a few links to the official UE4 documentation on blueprint scripting that I think you’ll find helpful:

  1. Basic Scripting — contains quick links to key concepts such as Setting/Getting actors, casting, etc.
  2. Finding Actors in Blueprints — shows a couple ways to access your world’s actors from within any blueprint
  3. Blueprints Visual Scripting — the “table of contents” documentation page for practically all things you might want to learn about blueprints; by spending some time reading the articles linked on this page, you’ll become very proficient in blueprints

Sorry I can’t be more specific: there are just too many ways to approach this, and each offers different advantages. It’s your choice, since you have the knowledge of how your project should be organized and designed.

I hope this helps anyway!

You are failing to cast properly. If you look at the first screen shot that works properly you will notice you first grab a reference to a specific object (owning player pawn), you then cast (ask the computer if the owning player pawn is of a specific type…“FPS_Character”) when this cast succeeds (the “owning player pawn” IS a “FPS_Character”) you now have access to the FPS_Character variables and can change the mesh material. Your second screen shot you fail to provide an “object reference” to apply the conversion into a BP_VaseOK thus this will never return any data to perform a material change on. Your other screen shot where you used “self” as the object fails because this is in a widget BP, and a widget BP is NOT a BP_VaseOK object. Your last screen shot again doesn’t supply an object to do the conversion with. You simply have a “mesh” reference with no object that is why it requires a “target”. Your issue lies in creating a proper reference to your BP_VaseOK object class. I have a tutorial that explains “casting” that you may find useful, I will post the link below. Let me know if you have any questions. (It is the first video in the playlist)

you need to get the actual object.
Where is the actor ? it’s owned by the player ? selected in a way ?

i think you should check the link given by @the_batch, learn a bit more and if you are still stuck we can still see to help you :slight_smile:

Thank you! I will check them out! :slight_smile:

Thank you! I found them very useful :slight_smile:

Thank you so much! I will watch them all and then try to amend my errors :slight_smile: I’m just learning how to use blueprints so I will find this very useful