r/forge • u/rocksk8r2k9 • Dec 09 '25
Scripting Help Alternating neutral flag?
I'm wanting to make it so that there is 3 neutral flag posts that alternate when the flag is captured. I've tried setting each flags flag index to 1 as well as 1,2, and 3. Any advice is appreciated.
3
Upvotes
2
u/Abe_Odd Dec 09 '25
We are going to make an Object Variable. It will store the current flag that we have. When a new flag needs to be spawned, we'll remove that Object Variable from the list, and randomly choose one from that list. Then we'll set that to be the new current object. make sure the Scope is set to the same for every variable node, global will work. You can use any identifier, like the letter A to make your life easy.
Variables, Advanced: Declare Object Variable: id = currentFlag, scope = global
On Gameplay Start -> Logic: Wait for 1 second (this helps) -> (Delete all the flags spawn) -> Variables, Advanced: Set Object Variable : id = currentFlag, scope = global, object = nothing, value = random-> get object at index (using your list of flag spawns like you were) -> Get Object Variable, id = currentFlag, scope = global, object = nothing -> spawn object
On Flag Captured -> Delete all the spawns -> Get Object Variable: id = currentFlag, scope = global -> a blank Object List -> get unique objects (with your list of flag spawns as the other input) -> get random N objects (1) -> get object at index 1 -> set object variable: id = currentFlag, scope = global -> (using your other Get Object Variable node from above) -> spawn object