Understand inverted take into account linked objects

At the beginning of the scene, i create a map of “Tile”. After that i want to pick randomly 5 “Tile” that is not linked to the “Dummy” to spawn “Dummy” on it and link it.

If i have 25 “Tile”, i expect it will pick all the “Tile” that is not linked to “Dummy”, pick randomly 1 “Tile” from them then spawn “Dummy” and then link them.

However, when i run it, it only spawns once. I tried multiple way to debug, it looks like my assumption was wrong. The inverted take into account linked objects doesn’t return “Tile” that is not linked to “Dummy”.

So i want to know what is wrong with my code, how the inverted take into account linked objects works and if possible, how to solve my problem.

Thank you for your time!

1 Like

Hi, welcome to the forums!

What is your end goal for the dummies?
Do you just want them to spawn in the room randomly and act as enemies? Why do you want them to link with the main Dummy?

Personally I don’t have a lot of experience with Linked objects so I don’t know what could be wrong here or why you need to link.

However for the Inverted condition, take note that it may not work for some conditions and you may have to use the NOT CONDITION
image

If you just want the dummies to spawn randomly, I did the below simple solution

My objects

The code

Final Result

However with this, the cheese (Dummies) may spawn at the same position…

So we will create, an object variable called occupied for the floor that it will turn to true if there is a cheese on the floor and to prevent further dummies from spawning on it.

By doing the below changes the dummies will always spawn on a tile that does not have cheese (Dummies) on them.

Instead of enabling the spawn action at the beginning of the scene, we will have a compare condition, that it will check if there are 5 (Or any number you want) of enemies on the screen.
If the condition is met, we will create a scene variable called EnemiesSpawned, that we will toggle to true in order to prevent the enemies from spawning…

Not sure if my solution is what you want, or if its a proper one. Still wanted to try. :sweat_smile: Let us know if this is not what you want.

1 Like

Ahhhh, I see, thank you so much! It works as I want! I link them with the floor because I thought it wouldn’t move. But if there were movable objects, i would be screwed up. After reconsideration, I should only link objects if they are parts of body or something. Anyway, thank you for your help, I learned a lot from your solution! ^.^

1 Like

Glad to see that it worked! I’m sure the more experient members can offer a better solution if needed.

Also here’s Gdevelop’s page for linked objects if you want to see how they actually work.
Linked Objects - GDevelop documentation

1 Like