A resource count mechanism in a trigger box

Good morning ! :slight_smile:

I’m developing a game with a friend, and I need some advice. So there is a safe zone which is represented by a small island and I delimited it with a trigger box. I would like to know, or have some advice on how to create a mechanism that would allow players to win the game once a certain number of resources (blueprint class) have been deposited in the safe zone (trigger box).

Thanks in advance !

Hi there!

Looks cool, and sounds fun! I think what you would want to do if leverage an event for the trigger box you placed for your “safe zone”: Trigger Actors | Unreal Engine Documentation

Maybe conduct a check that the resource is what overlapped the trigger box, and increment some variable that relates to your win condition.

Now, it’s tough to say from there how that variable should be setup without knowing more. For a prototype, you could use the level blueprint to store the variable.

How do you communicate when the variable should change from another blueprint? Probably with an event dispatcher: Unreal 4 Event Dispatcher - Talk to level blueprint from Player - YouTube

You may want to use a custom event, just depends on how you go about it. But in summary: use an event from the trigger box. Store the variable somewhere. Change that variable by binding the event to it.

The most generic and straightforward (albeit not too elegant) way would be to have the trigger count stuff; create an actor with a box and:

or:

There’s probably a dozen+ ways.


To do it better, count only when you deposit - how to do it depends on what deposit means.

1 Like

thank you both you helped me a lot! :slight_smile:

Everynone, your example works very well, I would never take your proposal, but I would like to know how I can add differents classes of resources (blueuprints), like it takes 2 plants, 3 woods and 4 fabrics to finish the game ?

1 Like

How do you deposit stuff? Players throw in the ground?

yes ! the player must drop it on the ground

There’s probably a bunch of different ways, some better than others. How to do it depends on the requirements. Check this out, it’s pretty generic and should be easy to maintain:

It revolves around this list, where you have X and need to satisfy Y:

I’d add another set of checks for items leaving the collision volume, in case we need to account for them getting removed.

1 Like

thanks you very much !

I’m sorry but I can’t figure out why my add function can’t have an integer pin (x, y)? maybe it’s different on ue 5?

Right click pins to split them.

I’m almost there, however the “check ressources delivery progress” function does not appear in the same way than on your screenshoot

Sorry for all these questions, you already helped me a lot! :slight_smile:

I am a beginner

Flag the function as Pure in its details panel. But it will also work as is if you connect it.

The locIsEnough is a local variable, local to that very function.

Thank you so much, that looks good to me! :slight_smile:

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