how do i check if i have the same object/number 2 times or more in an array ?
The contains node will help you with that…
I’m being lazy and using someone else’s example (sorry I don’t remember who’s as I saved these pics a long awhile back) so all credit to This dude who posted it…
This example is a trace that goes out straight forward from the camera and makes an array of any PhysicsBody that it encounters…
Break hit brings us to the 2nd pic attached where s/he Checks the Array to see if it Contains that actor already…
You can also use remove or a Foreach and likely many more ways to get the same results…It’s what’s fun about the Unreal Engine…1million ways to get results…
Array nodes - Array Nodes | Unreal Engine Documentation
if you have any questions…let me know…
Thanks man, I managed to do this an other way i didn’t even know there is a “Contain” node, good to know lol XD
How would i go and count the amount of Actors in an array, but being modular so i just get the amount of containing same actor in that array?
for example array is like this
Flashlight
Flashlight
Apple
gun
gun
can
How would i go about and output that there are 2 Flahlights, 1 apple, 2 guns and 1 can without filter array having to be set-up for all of them? So meaning it just gets the amount and i don’t need to create a new filter array for every item?
Is there a way for this? Not sure if i should reply with this on this old post but i figured it’s kind of in the same area?
Greetings,
Celeste
Use length to count the total number of items. For counting the number of each type of item, you are probably going to have to do that manually using a loop.
CelPlays I didn’t know how to do that myself, so I took it as a challenge to try and find something that works, I believe what I have in the screenshot below does the trick, it doesn’t require you to setup the filter array before hand yourself, since i imagine if you have many items it would be a pain in the ***. This will take in an array, and tell you how many of them are the same class.
Hey,
Thanks for your replies, meanwhile i also asked a friend and he came up with a nice solution.
Basically i forgot to cast to actor class which was the reason why i couldn’t connect get class to filter class.
However your idea could also work.
This is what also worked.
&stc=1Kind regards,
Celeste