Hello everyone. I am trying to increment a variable in my blueprint actor every time I place a copy of the bp actor into my level. Is this possible to do without getting into a c++ blueprint? Or if I could change the variable’s default value after every placement that would work too. I am simply using an int for an ID that I want to increment after every placement so I know the order that I placed the actors into my level. Thanks for any help!
In the construction script, just use ‘get all actors of class’ and find the one with the highest ID, and set the ID of this one to 1 higher
I sort of got it working but it was doing this weird thing where it would increment the ID every time I slightly moved the object as well so I tried setting a placed bool but now it won’t work at all. Any ideas? I also noticed the Print string never seems to appear on screen but maybe that is just a construction script issue.
Ah, no, ok…
Get all actors, except yourself.
To get the print string to appear
Also, you only need to set your own ID at the end
I can’t seem to get this to work. The construction script seems to continue to fire continuously with every slight move of the actor in the viewport so that is what keeps increasing the ID over and over. Is there a way to only get the construction script to fire once? Also, you said I don’t need to keep track of the highest ID number, but then how would I know what to compare my new value to? I thought I need to iterate through all the BP actors of this type and then just keep storing the highest ID I found and then just set my new ID to a +1 of the highest ID found?