Cloaked Games
Member
So, I think I already know the answer to my question, but I don't like it very much, so I'm asking here to see if anyone has any better ideas.
I need a way to separate objects into useful categories, so I can treat them correctly in collision events mostly, but it's useful for a lot of things. Right now, I'm using a lot of parent and child objects. For example, I have obj_type_wall which is the parent for all "solid" objects that the player and enemies cannot walk through.
This works okay, but now that my project has gotten fairly complex, this method is growing to be kind of annoying. Here's an example of where simple parenting trees do not work at all. I have two types of enemies, flying enemies and ground enemies. They behave exactly the same, except that the ground enemies behave like walls and will not cross the path of other wall type instances, while the flying enemies can go wherever they want. If I want to group them both under a parent called obj_type_enemy so that I can easily address both of them when I'm working with the player weapons, I have a dilemma. Either both of them will also have to be children of obj_type_wall too, or neither of them can be. Which means no matter what I do I am required to have extra checks in like, 2 or 3 different places.
I would like to find a way instead to reference objects by a tag, like in MC or something. "With a collision with all instances with the tag: "wall", stop moving". Or "target is equal to the nearest instance with the tag of "enemy" and the tag of "flying"".
There does not seem to be any way to check if a particular variable exists, which basically means I have to define a variable as either true or false for every single object in the entire project (which is like, 80). I could simplify it a little bit with a generic array or something with a list of tags but... it feels really stupid to define 10 variables for something when I only need to do checks like this occasionally. And like, if I forget one... It's just a hassle.
Sorry for the rant, is there any better solutions? I'm pretty sure the answer is no but... I want to check before completely revamping my project for the third time.
I need a way to separate objects into useful categories, so I can treat them correctly in collision events mostly, but it's useful for a lot of things. Right now, I'm using a lot of parent and child objects. For example, I have obj_type_wall which is the parent for all "solid" objects that the player and enemies cannot walk through.
This works okay, but now that my project has gotten fairly complex, this method is growing to be kind of annoying. Here's an example of where simple parenting trees do not work at all. I have two types of enemies, flying enemies and ground enemies. They behave exactly the same, except that the ground enemies behave like walls and will not cross the path of other wall type instances, while the flying enemies can go wherever they want. If I want to group them both under a parent called obj_type_enemy so that I can easily address both of them when I'm working with the player weapons, I have a dilemma. Either both of them will also have to be children of obj_type_wall too, or neither of them can be. Which means no matter what I do I am required to have extra checks in like, 2 or 3 different places.
I would like to find a way instead to reference objects by a tag, like in MC or something. "With a collision with all instances with the tag: "wall", stop moving". Or "target is equal to the nearest instance with the tag of "enemy" and the tag of "flying"".
There does not seem to be any way to check if a particular variable exists, which basically means I have to define a variable as either true or false for every single object in the entire project (which is like, 80). I could simplify it a little bit with a generic array or something with a list of tags but... it feels really stupid to define 10 variables for something when I only need to do checks like this occasionally. And like, if I forget one... It's just a hassle.
Sorry for the rant, is there any better solutions? I'm pretty sure the answer is no but... I want to check before completely revamping my project for the third time.