here it is looking more like the code you already have
This has been killing me for two days so I finally decided to post my problem here. I am spawning an actor into the world at a random spawn point. Then when I press the space bar, I want to destroy the actor and have it spawn at another random spawn point. I have this part down, but THE PROBLEM IS THAT I CANNOT FIGURE OUT HOW TO MAKE SURE THAT THE ACTOR DOES NOT SPAWN AT THE SAME POINT TWICE IN A ROW. I have read that I should use arrays but i am really having trouble figuring out how to get it to work.
Anyways, here is my setup so far.
In the game mode on event begin play: “Spawn Washer” is called and it selects a random “washer spawn point”, where it calls another event called (also called “spawn washer”) that is located inside the spawn point blueprint.
In the spawn point blueprint: the event “Spawn Washer” spawns the actual actor (its a washer )
Finally, inside the actual actor “The Washer”, when I press space bar, it destroys the actor, casts back to the game mode and calls the original spawn washer event (See first pic).
Once again, I just want to prevent the actor from spawning at the same point twice in a row. Any help would be greatly appreciated, and I apologize in advance for the NOOBOSITY of my question!
If you got Questions left let me know. Everything in a single BP you can drop it in Game Mode if you like.
You want to save your random number in “This Spawn Number” and then check that against “Last spawn number”(default to -1 so 0 has a chance to win). “Last Spawn Number” will be set with “TSN” if the numbers are not the same. On the second, third, etc., run if the random number is the same as the last spawn it will loop again until it does not.
ps. event begin play can be your custom event
forgot to mention- use “Get” with the integer from “Last spawn num” after you set it.
Thank you for the fast response! This setup causes an infinite loop, unless I change the > to a <, but then it still double spawns.
Whups yeah little oversight from me switch the Counter with the Length keep the > node as is. (or keep the < but then you have to switch the true/false ;P)
Make sure you dont already have placed what you want to Spawn in the Level. Its a good habit to use TargetPoints / Tags or a combination of the two for this. If you still experience double Spawns make sure you removed your old Spawn Code. The way I set it up makes sure that the Old Spawn gets destroyed but it won´t affect anything already placed in the Level by Hand.
Thank you! 100 spawns without any double spawns.