I have a bunch of iterations of the same blueprint in my scene. I want the player to go up and interact with each iteration of this same blueprint (click on each of the trees in my garden scene). I want to be able to track if all of the trees have been interacted with and then trigger something when that happens.
I tried using a count system, but each iteration of the blueprint was counting on its own instead of one total count. I think I need to be using booleans but I’m not sure how to approach it.
Cool event could be a custom event that fires off, or an event dispatcher, or something like that.
Please let me know if this works, or if you have any other questions!
If you didn’t want to use event tick (Optimization issues ) You could fire this code off in your tree blueprint. Where the event tick is, there could be something like an interact action mapping that you fire off. But the code after that would be the same.
Again, please let me know if this works, or if it doesn’t. Cheers!
I usually make master blueprint, it gets all actors of class (your blueprint) sets up int32 counter, then for each of that blueprint sets int counter variable.
So all those blueprints of that class have unique int32 ID.
With that stuff working, i make child CLASS of such blueprint, so all my blueprints that need ID have some unique number.
I just mean an action that the player fires off. Like the C pressed, or released node in your blueprint.
The all tree blueprints needs to be in the level.
Something else you could try is not a for each loop, but a for each loop with break. That might work , but I’m not quite sure.
oh okay cool. I tried that out and it triggers the event (just a printtext right now for testing) 13 times for the total number of trees. It’s still not separating the trees as individual items.
While i was doing this code I had suspicious thought, do you want those IDs so you can for eg. write down, that item 10th is door at some place, and item 11 is door at another place? If so this will not work IDs are given in order items spawn they may differ from one run to another.
System that keeps same IDs trough different runs, and trough development would be much more complicated.
ps.
Well maybe not you just need to get some stuff that does not vary from run to run and make out of it something like serial numbers for games do.
Just found out a way: “Create new GUID” and then “Guid to string”, those two nodes give you unique guid strings, that you can use to identify actors. However again they will be generated for each use, so every run new set of guid strings and you probably want same strings/ids always for things you created.
I can not think of automatic way that does this without you going heavy on copy paste side.
ps2:
you can always make int32 ID variable, expose it to be editable in blueprints, and manually set those variables. Or look into gameplay tags, create your new custom tags, and set manually for actors.
As usual I was overthinking. Above is more generic idea for keeping track of items, and sadly there is no automatic way to keep same ids for same items during whole development, i think it needs human input somewhere.
Anyway here is simple code that will manage your trees without caring which tree is which, this only counts untouched trees.
EVENT_ChangeState sets materials for test cube mesh. EVENT_CountTrees counts untouched trees, and if it’s ZERO, it sets the state to ALL touched. However, this only happens in the last checked tree blueprint. I did not add a dispatcher, etc., to keep it simple. So other trees/blueprints do not receive event to change state.
ps.
To keep track of separate trees, you can read actor name in blueprints, and create map variable that holds name of actor as key, and state as value.