1 object, 2 team turrets, targeting is broken

Hi I am now having a quite of an issue with my own project.
In this one, there are satellites that act as turrets and it is just 1 object acting for 2 teams. These turrets now have an issue regarding their targeting of other turrets.

What just happens is that the turrets instead target themselves and their own team instead of the opposite.

The system I tried making for this is that if the boolean variable “friendly” is true and the distance is 1000 for the turret then it instead tries to shoot the other team instead.

What happens instead is that it just shoots any satellite objects with a messed up target.

Here is a link for what it looks like:

Hi! Interesting issue you have going on here. What I would likely do is:

  1. Create an invisible target object (let’s call them ‘targob’) and assign one to each turret.
  2. Link them together and have the targob move to the same position as it’s parent turret.
  3. Create an id variable for them as well, both turret and targob.
    Each targob will have the same id variable as it’s parent turret.
  4. When targeting, the turrets will only look for targob with different id variable from itself.
  5. …?
  6. Profit!

And that’s it.
Maybe linking might not be necessary since the id variable can probably be used for such purposes, but idk. And this is just how I’d imagine it would be done, still I’m curious if there is an easier, or more efficient way to do it… Here’s hoping some pros would come along and show us how it’s done.

I mixed Levio concept with mine.

Try me, the objects are draggable
https://gd.games/instant-builds/b892b0d8-0861-4c0c-b2b2-18e0190a1ee6

The satellites have 2 animations, one for each team, the fire and draggable behavior
The fireballs have 2 animations, one for each team, the destroy outside behaviors
The Target has the sticker behavior

The satellite and fireballs have a number variable name Team. Some satellites are set to 0 and some to 1. I guess I could’ve just set the animation. I just changed my concept and didn’t think about it. The animation could be used instead of an object variable. That’s up to you.

My project, click the green [code] and then [download zip]
https://github.com/doug13579/Gdevelop-target-satellite-using-teams

1 Like

Ah, it totally slipped my mind that there were only supposed to be two teams. Here I was overcomplicating it and going for dozens of teams and free-for-alls… hence the variable approach. lol.
Apparently, with just animations, simplicity is best. Thank you, sir.

1 Like

I honestly can’t tell what’s happening in the video. The nice thing is this works with any number of teams. It would probably work with a group if needed.The team number is the important part. It’s a simple foundation.

1 Like