x

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 create a constant in blueprint?

How can I create a constant (a node containing a value with one output) in Blueprint?

Product Version: UE 4.11
Tags:
more ▼

asked Apr 27 '16 at 01:03 PM in Blueprint Scripting

avatar image

Arthur Masson
299 36 44 61

avatar image goncasmage Apr 27 '16 at 06:11 PM

I don't think you can... that feature is mainly a performance reducing one in C++, and blueprint doesn't really work like that i guess...

avatar image Bronzdragon Feb 04 '18 at 07:03 PM

It's not only a performance feature, but it's also to save yourself from making mistakes. If it's a constant value, you can't accidentally write a different value to it. You can also instantly tell that it will only ever have one value. It'll save you headaches later down the line when you go "But how come this value is changing?!" while debugging.

avatar image ThompsonN13 Feb 04 '18 at 04:15 PM

try using the make literal node. of course this depends on type of value that you want to be a constant but you can use a make literal in a variety of situations. you could also use variables, addition nodes, and conversion string to int or something like that.

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

4 answers: sort voted first

I think I found best way to do constants using blueprints - Macro Library. Just create one and then in there you can create simple macro like this...

alt text

And then use it whenever you want, no need for execution pins, acts like getter for a variable.

alt text

more ▼

answered Dec 13 '16 at 10:33 PM

avatar image

Daniel K.
160 9 21 23

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

To create a variable node, you can select and drag an input, and on the context menu which pops when you drop, select: "Promote to variable".

more ▼

answered Apr 28 '16 at 12:38 PM

avatar image

Arthur Masson
299 36 44 61

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

You can make the variable private and create a BlueprintPure (enable const) that returns the variable. This way no other classes (even child classes) will be able to set that value to anything else.

more ▼

answered Apr 27 '16 at 08:07 PM

avatar image

ryanjon2040
1.6k 55 43 93

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

functional programming workaround for class dependent constants:

alt text

keep that function pure also.

screenshot-5.png (26.3 kB)
more ▼

answered Feb 04 '18 at 01:20 PM

avatar image

Arty-McLabin
893 20 42 62

(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