Using A Loop To Streamline This CODE

Hello,

I’ve been at this for hours, so I figured I’d reach out to help save me time. I’m trying to test for multiple instanced overlaps, and I’m successful here:

However, I know there’s a better way. I’m missing something in how ForLoops function, because this doesn’t work:

I thought it would run the function each time with a different index, but maybe I haven’t set it up correctly? Unsure.

Add a tag to the components and check for that?

Are there more instances in the world? Spawned at runtime or placed in level?

Why not just check the class of the other actor?

Hey,

Normally, yes, however, the issue is that there is a specific component that is overlapping that I do not want to overlap. I’m going to scrap this project, as it was merely for learning, but I do want to figure out why my FOR LOOP is incorrect.

This is not scalable. At least, retroactively. HOWEVER, it is a great tip, nonetheless.

BUMP

In your second picture, the branch has a condition of True, and you’ve only connected code to the false path, so that will never run

1 Like

it’s all guess work until we get more info about the problem. Maybe the design is the problem?

1 Like

You’re correct. I was being lazy. (Didn’t want to redo everything again.)

Here’s what the code actually looked like:

Shouldn’t it behave identical to this?

I just want to know if I set this up incorrectly. My approach is wrong (for what I want) but I want to know why my understanding of the For Loop is incorrect.

1 Like

You connected them all to other actor…the first picture has something connecting to other component.

I’m unconfident with my English so I draw a picture :slightly_smiling_face:

1 Like

I’m not even going to try to begin to write Chinese, so, yes, your English is great.

I know this sounds hokey, but I wish I can give everyone credit, because you all helped me get to resolution of this issue. Bao pointed something out that would have driven me nuts, so, there’s that.

The problem was the the loop was only taking the LAST variable value. So, conditions would be:

1,0,1 → 1
1,0,0 → 0
0,1, 1-> 1

etc.

I noticed that if I changed the “Last Index”, the bombs would only work in THAT index.

So, I understand loops, thankfully, but my logic was incorrect.

1 Like

not really the question but this is a good use for an interface, just call ActivateTurret or whatever and on the target if it implements the interface run any addition checks there.

fire and forget

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