Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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: alt text

To this something like this: alt text

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.

Product Version: UE 4.21
more ▼

asked Jan 04 '19 at 02:45 PM in Blueprint Scripting

avatar image

6 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

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 )

more ▼

answered Jan 04 '19 at 03:26 PM

avatar image

1.5k 14 18 32

avatar image ester_8a Jan 04 '19 at 05:08 PM

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

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

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.

avatar image Firefly74 Jan 04 '19 at 07:14 PM

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 :)

avatar image ester_8a Jan 04 '19 at 10:22 PM

Thank you! I will check them out! :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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!

more ▼

answered Jan 04 '19 at 05:51 PM

avatar image

1.2k 4 5 8

avatar image ester_8a Jan 04 '19 at 10:23 PM

Thank you! I found them very useful :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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)


more ▼

answered Jan 04 '19 at 06:53 PM

avatar image

Nebula Games Inc
5.4k 28 9 14

avatar image ester_8a Jan 04 '19 at 10:25 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question