Setting up multiple trigger volumes in an array

Hey, I’m currently working on section 3.

How would I go about setting up multiple trigger volumes to feed into door open mechanic?
What I have in mind would be an array of all trigger volumes but I have no idea how to do this.

I have one trigger volume where the sun shines on the ground and another one on the table:

It should be almost no different from assigning one.

It looks like each TriggerVolume has its own object or identity so duplication doesn’t seem to work here. So a TriggerVolume variable is created for each TriggerVolume in the door class header for opening the door and compile. In the editor you then assign each to the door. Since they have different variables you then just check each of them.

Thais what I generally want to avoid since I’m planing to build a level with 20+ trigger volumes but I want them all to contribute to a unlock mechanic. I think assigning each trigger volume would be very inefficient.

Thanks anyway.

In the OP you only specified 2 TriggerVolume’s :slight_smile:

But still, you have to check the objects that have entered each TriggerVolume otherwise nothing or everything will trigger the door. It is what it is. So you either need to do something else or live with it.

If you don’t mind anything triggering it then you just do a quick check for first overlapping object which will cut down on execution time by potentially a lot or less but still more than if only checking for character.

As in you want them to all be “solved” in order to open one door or have each one be able to open one door?

Yeah all solved or all contributing

for example:
to open door you need 30kg-> you can distribute the mass on all trigger volume->
the mass on all trigger volumes gets added-> to check if set target mass is reached->
if true the door should open

Ah so not what I was thinking then. I thought you were asking for each trigger volume needing a specific mass, so multiple puzzles solved = door opens.

Though for what you want I would iterate through ATriggerVolume (unless you have other trigger volumes for other purposes) and bind to their Begin/EndOverlap events which adds to the mass

TActorIterator docs

So outlining it would be something like.

BeginPlay:
for Volume : ATrigerVolume
Volume->OnBeginOverlap.AddUniqueDynamic(this, &UOpenDoor::...)
Volume->OnEndOverlap.AddUniqueDynamic(this, &UOpenDoor::...)

Begin:
TotalMass += Actor->Mass

End:
TotalMass -= Actor->Mass
1 Like

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

Privacy & Terms