Why cant I Set/Update a MAP variable in Construction script?

UE4.27

  1. Can Construct really not update certain variables like Arrays or MAPs? (It works on changing Meshes and Light colors.)

  2. How can I Set/Update a MAP variable in Construction script? - these nodes are not working:


  • I have a complicated Function that is used in Event and Construct - in CharBP and pickup Actors. So I made an external Function asset (so when I update the code, I only have to change once); and have CharBP and other Actor reference that Function in their Construct script.

  • I set the Map variable (in CharBP) to Instance Editable.

  • But in CharBP > Construct > the MAP value will not get Set/updated - based on the feed line from the Function OUT pin and/or the nodes are not working in Construct?

  • The MAP variable is an Enum > mapped to a Name (which represents a DT Row name).

  • I want the MAP to only have one of each Enum. E.g. one Head, one TOP, one SHORTS. So I’m open to use any Node that can update/replace a specific Enum & [“new Name”] in the MAP, if that Enum already exists with [“none,” or “old Name”].

What is wrong? Please help. Ty

Is there an unreported bug with CS not updating Vars, and UE4.27?? (Ive found many threads reporting this issue.)

In the older version, someone could even set a Var in CS without setting it to Instance Editable.

Yet in UE4.27, I cannot set a MAP or Array var in CS, when both are set to Instance Editable (which I believe they changed - that it is now required to be on. But still CS wont update my Map or Array vars???)

Setting maps, sets or arrays work normally in CS, are you sure something is comining out of your “external function”?

Thanks for the reply.

  1. It should be, according to my pic 2, at the Return node.
    Correct me if my code is wrong.

I can have inputs AND outputs in a Function, that runs in CS, correct?
(I know the inputs are working because I have 6 chain links of the Function [node], and the CS changes each mesh/mat. When I change a DT Row variable in my CharBP > the CS fires and instantly updates the Mesh. So I know the External Function is working in my Char’s CS - except setting the Map var.)

  1. And for my pic 1, which node should I be using in CS to set/update the Map? Ty
  1. You have something plugged to the return node, it doesn’t mean a value is outputting. If it doesn’t find the enum from your data table, it won’t set the “category” variable, and it won’t be added to the map. It could also not find the row
    I assumed the picture 2 wasn’t your “external function” because it has an integer output on pic 1 and not on pic 2.

“I can have inputs AND outputs in a Function, that runs in CS, correct?” That is right, but you have to be sure these inputs and outputs are correct, and handle the situation when they are not. Have you tried to use print strings to debug?

  1. The “add” node is the one to use to create OR modify entries in maps.
1 Like

Ty for the Add node confirmation. So I was able to test.

Correct, the pic isnt my full Function. It is 70% bigger, so I only showed the needed parts to make discussion easier.

  1. I could not confirm the above prior, because I didnt know how to Watch Vars > display live values changed by Construct Script (since I cant press Play to start Debug mode and fire CS?)
  2. And the Right panel was not updating the values of my Map (in Editor).
  3. So I right clicked on the text of the Map var > watch. And I added a node as a breakpoint. Thus I could Play the game (in a new window) while seeing the Editor Graph in another.
  • Now the Editor did show a popup display of the live Map values - to prove that CS updated them (CS code worked) before I pressed Play (to confirm).
  1. (And later I found out how to Print Map values.)

  2. #3 and 4 proved that UE4.27 is not updating the Right panel > values of Map while in Editor. Why is this?

The variable won’t update in the right pannel, that is normal. The value in the right panel is a default value.

Here is a test I made. It creates a map (enum/name) from an enum, then prints the map keys and values :

As you can see, there is no default value on the right pannel, but the print proves everything has been added (I have a bug where prints string doesn’t print to screen but it still prints to log. Normally it should be printed on screen as well) :

Use print instead of watch value in your function to check what is the row name asked to the data table. Don’t forget, prints in CS appears only when you compile, when you modify the actor on the scene, or on begin play.
If you have no name on the print, then you have to check what happens before (for example the structure that the name come from). If it prints the correct name, check what happens after (for example is the exact name exist in the data table?)

2 Likes
  • Ok, thanks for the confirm. So my question is why didnt they make it update in Right panel (so that I wouldnt think my CS code was NOT working)? Seems counter intuitive.

I saw so many people complain that CS was not updating their Vars - but it was merely not displaying the update in the Right panel (as we think it should).

Also I see your highlight pic > Right panel > no Indexes are set for your Map. Perhaps Map is an exotic variable and I’m thinking of it wrong. And Maps are only used as Cups to fill up once in game?
(I wanted to preset a list of 6 DT rows > to load my Armor. I couldnt get that to work. So I had to make 6 single variables of DT row handles instead.)

Ty :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.