I can't connect multiple walls with one trigger

How do i connect multiple walls to one trigger.


It only moves the last one.

Because you the trigger only has one mover variable. It’s similar to this

// Your different actors
int Actor1 = 10;
int Actor2 = 20;
int Actor3 = 30;
int Actor4 = 40;

// Your one Mover on your trigger component
int* Mover;

// Your blueprint code
Mover = &Actor1;
Mover = &Actor2;
Mover = &Actor3;
Mover = &Actor4;

// Your movement code
*Mover = 100; // Actor4 = 100, you setting Mover to ShouldMove

// Actor1 == 10
// Actor2 == 20
// Actor3 == 30
// Actor4 == 100

You would need to make it an Array and loop over them. i.e. change

UMover* Mover;

to

TArray<UMover*> Movers;

P.S. You don’t need to get the trigger component every single time.

I changed it but now i get a bunch of new errors.

I changed the name of the variable from Mover to Movers as it’s now an array of MoverComponents.

But where did you change it?

In the code I posted. I’m not sure I understand your question?

when i do that the error that i posted in my screenshot pops up.

I think you didn’t understand me. You renamed the variable because you copied and pasted my code which renamed it to be plural.

This means all your usage of this variable needs to be updated too. (Or remove the s and keep the original name)

So i kept my original name and didn’t change anything except for the header file but it reports this error.

Right, because it’s now an array so you’ll have to loop over it.

SetMover should be renamed to AddMover and you would just do

Mover.Add(NewMover);

instead of Mover = NewMover; ?

Correct.

It still reports 4 errors.

Those were two separate issues I listed above. You need to loop over the array to set them to move. Looping similarly to as you did in GetAcceptibleActor.

i don’t really understand how i should make my loop.

Did you not understand the lecture on range-based for loops?

I don’t remember.

In that case I suggest you re-watch it.

so i should loop this
Mover->SetShouldMove(true);
and this
Mover->SetShouldMove(false);
seperately or together?

The only thing that’s changing is that for each of those two statements you now loop over an array.

Privacy & Terms