Herding Mechanic? Part 2

Hello,
I am wondering how to program a sort of collecting mechanic that keeps the score of how many sheep have been herded in a certain area and when they have all been collected in that area the timer will stop and my widget for completing the task will appear.

If someone can show (with images) how to do this that’ll be great!
thanks!

How about this? You have a ‘herd zone’ which is just a BP with a collision volume the size you want. The code goes:

It just watches for sheep overlaps, when the ‘sheep in zone’ gets big enough, you can trigger your event…

Hello! @ClockworkOcean

Thanks for the suggestion.
What BP would it be though?
Also would the “Sheep Zone” be an integer? If so, when I tried implementing the floats for + and - I had to convert it(?)

Like I said above ;), HerdZone is an actor BP you make yourself. You put a collision box component in it, and then put that code inside.

You can tell SheepInZone is an integer because it’s green…

Thank you! The herd zone works!
Although is there a way to get it edit when the widget comes up?
Because with the + increment as soon as one gets in the widget appears.

hey clockworkocean floats are green too lol.

if your looking to modify the value displayed by the widget then you just need to modify how you get the value. for example you could create a binding to the variable sheep in zone which would require you to have a reference to the herd zone actor (or where ever you store the variable). or you could add a script that gets the widget and sets the value whenever the variable’s value changes, for this you would need a reference to the widget in the herd zone actor. theres also many other ways.

i hope thats what you were looking for. your post was a bit hard to understand.

Hey Thompson: Not that kind of green :wink:

haha true enough

Hello, @ThompsonN13

Let me explain, I have a fence that I would like to program it that once they pass the gate/opening there will be code that keeps track of how many characters have passed through it. Once the required amount/all the cattle are in that fenced area, a widget will appear and the time will stop.

I hope that helps.

ah yea thats pretty simple and theres a few ways you can do it.

first off you can do like clockWorkOcean showed above to increment and decrement your value. then after that you get the value of the sheep in zone variable and check to see if its the number your looking for, so if sheep in zone greater than or equal (>=) to X then a branch. if the branch is true then create your widget. (note thirdperson char = sheep)

a second method you could use would be to on begin overlap with a sheep you get all overlapping actors of class sheep and compare the length of the array to the number of sheep needed. then create your widget if true.

Ah! Thank you so much! This actually works now!