Reassigning Actor References inside a Map

Hello!

I’m working with a Map that is an Integer : Niagara Particle System Component Reference mapping.

I’m running into an issue where I am trying to reassign values from one key to another key.

My Map has 9 elements (0 thorugh 8, inclusive), each containing a reference to a particle system spawned on the map. During runtime, I want to move these particle systems from one key (say Key 1) to another key (Key 5). In the process, I want to remove the original reference being overwritten (in this case, the System Reference in Key 5 will be deleted).

However, when I try to update the Particle System references to a new key, the operation fails. It seems that the references are not being overwritten in the map.

Attached are a few pictures of what I’m working with. I can post more if needed! Any insight is appreciated!

Deleting some values:

Trying to replace:

I originally tried to use the same map with the ‘Add’ node, but that didn’t work. I now am trying to create a different map, and reassign it to the map I need.

Thanks!

Here you are telling it to find keys -2 and -1, and since you are going from 0->8 it should return false (assign default value). Are you trying to shift all keys/values?

If I understood correctly, this could help:

This is the result:

LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 0 | Value: 0
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 1 | Value: 1
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 2 | Value: 2
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 3 | Value: 3
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 4 | Value: 4
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 5 | Value: 5
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 6 | Value: 6
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 7 | Value: 7
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 8 | Value: 8
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] ** CE_MoveValue ** 
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 0 | Value: 0
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 1 | Value: 1
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 2 | Value: 2
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 3 | Value: 3
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 4 | Value: 4
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 5 | Value: 0
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 6 | Value: 6
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 7 | Value: 7
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 8 | Value: 8
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] ** CE_MoveValue ** 
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 0 | Value: 0
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 1 | Value: 1
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 2 | Value: 2
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 3 | Value: 3
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 4 | Value: 1
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 5 | Value: 0
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 6 | Value: 6
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 7 | Value: 7
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 8 | Value: 8
1 Like

Hi:

Yes, I am trying to shift all values. For your first picture, the ‘First Index’ is actually an 8, not a 0. I can see how in the picture that became confusing. I’m trying to shift them all ‘down’ by 3 in the map, while deleting the bottom-most ones.

In the past few minutes, I’m managed to get this going. I think that it works, but need to fully implement it:


Perhaps a map container is not the best tool for this. An array should work just as good and is easier to move stuff around. You are basically trading array index for keys.

Anyways, this should shift them around:

First groug is default map
Second is moving 0 to 5, deleting value at 5 and shrinking map -1 key.
third is moving 1 to 4, deleting value at 4 and shrinking map -1 key.

LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 0 | Value: 0
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 1 | Value: 1
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 2 | Value: 2
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 3 | Value: 3
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 4 | Value: 4
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 5 | Value: 5
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 6 | Value: 6
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 7 | Value: 7
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 8 | Value: 8
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] ** CE_MoveValue ** 
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 0 | Value: 1
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 1 | Value: 2
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 2 | Value: 3
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 3 | Value: 4
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 4 | Value: 0
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 5 | Value: 6
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 6 | Value: 7
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 7 | Value: 8
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] ** CE_MoveValue ** 
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 0 | Value: 1
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 1 | Value: 3
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 2 | Value: 4
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 3 | Value: 2
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 4 | Value: 6
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 5 | Value: 7
LogBlueprintUserMessages: [BP_SwapMapValue_C_1] Key: 6 | Value: 8
1 Like

I originally was using an array, but each of the Keys is representing a local grid coordinate. Having to worry about arrays automatically resizing when removing an element was something I wanted to avoid.

Thanks for the help! For now, I’m going to mark this as solved :slight_smile:

1 Like