Description

This behavior was not observed up to UE 4.19, but it can be reproduced in all versions from 4.20 to 5.4.

When a "Literal Enum" node is used inside a blueprint and an enumeration value is chosen from the available dropdown, the output correctly matches the selected value.

However, if the node has any connection to its input pin, the output ignores it and always incorrectly returns the default enum value (index 0).

While this is an odd usage of the node, the Engine allows it, and when it happens the resulting behavior is very difficult to debug, unneccessarily costing user's time. Also, the proposed fix is very quick and straightforward to implement and test: simply treat the node as a "Reroute node" when an input is connected. This can be done by adding the following code to function "UK2Node_EnumLiteral::ExpandNode()" after the first (bSuccess) test:

UEdGraphPin* InputPin = FindPinChecked(GetEnumInputPinName());
if (!InputPin->LinkedTo.IsEmpty())

{ // If the input is in use, we simply tie the input and output pins together, just like a reroute node (see UK2Node_Knot) UEdGraphPin* OutputPin = FindPinChecked(UEdGraphSchema_K2::PN_ReturnValue); const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>(); K2Schema->CombineTwoPinNetsAndRemoveOldPins(InputPin, OutputPin); return; }

 

Steps to Reproduce
  • Open any project
  • Create a BP actor and place it in the level
  • Implement BeginPlay() by using two "Literal Enum" nodes (of any Enum type) chained together, and printing the output as a string.
  • Use the dropdown in the first "Literal Enum" node to select an entry different from the first.
  • PIE. The BP will print the name of the first enum entry, and not the one that was selected from the dropdown.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-215264 in the post.

0
Login to Vote

Unresolved
ComponentUE - Gameplay - Blueprint
Affects Versions5.4
Target Fix5.6
CreatedMay 17, 2024
UpdatedSep 30, 2024
View Jira Issue