How do I get objects with a number variable to chase another object?

Currently I have a zombie, who has the object number variable team set as 2. This means he isn’t on any other team that doesn’t have 2 as it’s number variable.

If I just have condition zombie, action move towards character. It can do it no problem.
If I add the condition, object number variable = 2 to the conditions though it just sends the zombie to 0,0 and then the debugger actually is blank when it reports the zombie’s location.

Does anyone have insight? I can provide a video of what I am talking about too.

Anyways, thanks for reading and I hope your own projects are going great.

Can you screen snip the events relating to what you’ve just posted? It’s hard to work out what’s going on with a general explanation.

Not a problem

Can you also give a screen shot of this when you apply the extra condition?

And to check, when you use the debugger you are selecting an instance of the zombie, and not the object group name (just clicking on the word Zombie in the debugger will show a blank panel)

Hey MrMen, yes let me get you a screen shot of that as well.

So the good news is I can’t get it to replicate the blanks in the x and y positions like it was showing me before. It is still going to 0,0 though. Here is the events sheet.

However, all units should be going to the character location.

Is Character a member of the object group Units?

So, I may have found part of the problem. I have my computer controlled units and my player controlled units under the same global group. I have duplicated my units group events but assigned them to the player group and it appears to have fixed the problem.

lol your reply came in while I was typing. So it seems like I was on the right track. Do you happen to know why that was causing an issue? My thought process was it wouldn’t matter if it was apart of the same group because I am just getting the coordinates from it so even if it is a part of it it would just be updating the coordinates the whole time to exactly where the character already was. Maybe this is what has randomly caused huge lag spikes as well . . . . .

If Character is a member of Units, then when you select by Team id, you probably are excluding the Character object from the GDevelop filtered list of valid objects. Because of this, the reference to Character in the actions is a reference to an object not in the list, and so nothing is selected, defaulting to the (0,0) target location.

One way around this is to put your Character position into variables in a separate, unconditional event before you move the units and use those variables in the move action.

1 Like

Thanks I appreciate that, I believe I might do that as a scene variable. Your idea is way better than the solution I came up with. Thanks for the tip!