saving struct variable does not work for me

So I have a pattern made out of cubes and I want to trace from each side to detect if there is another cube nearby, if true then i want to set the value in the map.

I have a Map variable with mesh as a Key and my struct as a value for each side.
As I understand if I use Map ADD node and I already have a same key with value it will change the value for that key ?

this is my code at the moment. After looping side check for current mesh I check to see if all sides are true, but some sides are marked wrong.

Am I overwriting the struct booleans somehow with each mesh ?

6 Likes

When is edirection set?

3 Likes

I increment my eDirection right after setting the struct member

2 Likes

Another thing I should mention is I try to run it within construction script.

I’m not sure if trace by channel works there or not cause lines appear and if I uncheck ignore self I get a hit.

And that’s the reason why my struct bools dont get set cause (except last trace for some reason is always true) trace does not register my spawned static mesh components (I have set collision enabled and visibility channel to block)

3 Likes

That’s fine, but

Yes, sorry, you need that unchecked, because all the mesh components are part of this one thing.

But… don’t trace from inside one of them.

This works fine

3 Likes

Can’t test it at the moment but this also works when they are right next to each other ?

4 Likes

Right next to, no :slight_smile: It can’t.

You’ll need another method if you want to do that. Like keeping a record of coordinates used.

3 Likes

Okay thanks for your help, I can try to get location of current mesh and go through array and check actor locations and check if they match my mesh location + vector for each direction and add meshes as adjacent with struct and a map I guess

4 Likes

you must be having problems right. i found it still works

3 Likes

I got the trace to work, but the struct problem is still there something is overwriting the information cause on set struct member I check the value and draw debug just to confirm if the value in struct is correct.

but at the end all the values are wrong. First I thought that adding value back into map wipes all other bools to default value (false) so I made local var for that map key and carried them over, but that still didin’t help.

Is there another way to have array of bools for each mesh ?

1 Like

Ok, I think you are actually overwriting them.

If you have this sort of struct

and a MAP like this ( not an array ). You’re using a map, but calling it an array :slight_smile:

image

I can talk to one of the faces with the actual ‘set members in struct’ node ( you just have a function with the same name )

This will set the forwards element to false without touching the other three :slight_smile: ( because it’s the only one showing on the node )

Thank you that worked there was the problem with Map “Find” node giving a copy and then “Set member in STRUCT” making a ref of that copy, but not actually changing anything yet so I still had to add it back into the map with the current key to actually push the change into the map.

last question that’s related to output log that I used to debug it I don’t understand why it prints out the info 6 times

Some of them have correct info some not.

Picture of mesh location

LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Mesh: NODE_AddStaticMeshComponent-0_6
---StartingStructValues---
Forward: false
Right: false
Backward: false
Left: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Forward direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Forward direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Right direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Right direction to: true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Backward direction hit result is:  true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Backward direction to: true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Left direction hit result is:  true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Left direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Mesh: NODE_AddStaticMeshComponent-0_6
---ForLoopCompletion Struct Values---
Forward: false
Right: true
Backward: true
Left: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Mesh: NODE_AddStaticMeshComponent-0_6
---StartingStructValues---
Forward: false
Right: false
Backward: false
Left: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Forward direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Set Forward direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Right direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Set Right direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Backward direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Set Backward direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Left direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Set Left direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Mesh: NODE_AddStaticMeshComponent-0_6
---ForLoopCompletion Struct Values---
Forward: false
Right: false
Backward: false
Left: false
LogUObjectHash: Compacting FUObjectHashTables data took   1.83ms
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Mesh: NODE_AddStaticMeshComponent-0_6
---StartingStructValues---
Forward: false
Right: false
Backward: false
Left: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Forward direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Forward direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Right direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Right direction to: true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Backward direction hit result is:  true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Backward direction to: true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Left direction hit result is:  true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Left direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Mesh: NODE_AddStaticMeshComponent-0_6
---ForLoopCompletion Struct Values---
Forward: false
Right: true
Backward: true
Left: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Mesh: NODE_AddStaticMeshComponent-0_6
---StartingStructValues---
Forward: false
Right: false
Backward: false
Left: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Forward direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Set Forward direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Right direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Set Right direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Backward direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Set Backward direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Left direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Set Left direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Mesh: NODE_AddStaticMeshComponent-0_6
---ForLoopCompletion Struct Values---
Forward: false
Right: false
Backward: false
Left: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Mesh: NODE_AddStaticMeshComponent-0_6
---StartingStructValues---
Forward: false
Right: false
Backward: false
Left: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Forward direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Forward direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Right direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Right direction to: true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Backward direction hit result is:  true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Backward direction to: true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Left direction hit result is:  true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Left direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Mesh: NODE_AddStaticMeshComponent-0_6
---ForLoopCompletion Struct Values---
Forward: false
Right: true
Backward: true
Left: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Mesh: NODE_AddStaticMeshComponent-0_6
---StartingStructValues---
Forward: false
Right: false
Backward: false
Left: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Forward direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Set Forward direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Right direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Set Right direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Backward direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Set Backward direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Left direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Set Left direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_1] Mesh: NODE_AddStaticMeshComponent-0_6
---ForLoopCompletion Struct Values---
Forward: false
Right: false
Backward: false
Left: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Mesh: NODE_AddStaticMeshComponent-0_6
---StartingStructValues---
Forward: false
Right: false
Backward: false
Left: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Forward direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Forward direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Right direction hit result is:  false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Right direction to: true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Backward direction hit result is:  true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Backward direction to: true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Left direction hit result is:  true
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Set Left direction to: false
LogBlueprintUserMessages: [BP_TEST_Pattern_Rook_C_0] Mesh: NODE_AddStaticMeshComponent-0_6
---ForLoopCompletion Struct Values---
Forward: false
Right: true
Backward: true
Left: false
1 Like

Are you running it from the construction script? Then it will run multiple times.

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