I have a 2d game where you spawn and raise birds which are called “birbs” (I know, soo unique) And enemies called MiniBats try and eat them. I need to come up with a system where either A, they lock in on and go to the nearest birb, Or B the birb they chase is randomly selected. Whichever one seems easier, help would be greatly appreciated.
Well the first solution seemed to work in theory, but not in practice and so I thought, hey maybe there’s a simpler way to do this which is just picking a random birb. Thats why I made this to A get the first one fixed or C figure out how to patch together the second one. If you like, I could post the birbs finished AI and the Minibat nodes here.
Definitely. Marking the subject as solved when you know it isn’t is very misleading. There’s also no need to create a new topic just to prompt the forum to answer a variation of the same question. If you were unhappy with the solution we provided in the previous post you should’ve just said so. We would have tried to help you arrive at a solution you’re happy with.
On a more personal note, it doesn’t look like you’re thinking about your issue for more than a few minutes. Programming is not always simple and easy. Lots of problems can take days to solve - even if they are simple in concept. If you’re impatient and unwilling to think about the problem on your own, that’s just outsourcing your work to the community.
Use the great resources that are available on the internet to learn programming and get familiar with Godot as a whole.
Well, at this point going to the community is my last resort. I’ve looked at tutorials coded my own things mixed the two together and none have worked for my purposes, if they worked at all.
It has to do with the birbs constantly spawning in different places or dying. I have to find away for the bats to keep track of them all. That is the part I could never figure out. Every other aspect of the game hinges on the bats functioning properly which is why I want to code them as soon as possible.
Alright. There’s a simple way to keep track of specific instance(s) without the need to do it manually (e.g. by adding/removing instance in an array).
I’m talking about using groups.
Using groups
For each node, one or more groups can be assigned.
When making a script, you can use the following code to retrieve all nodes within a specific group.
var birbs = get_tree().get_nodes_in_group("birbs")
All you have to remember is to assign the birbs group to your birb-scene