I’m a beginner and I’m trying to design an autobattler game where both teams use identical units. The number of teams and the units each team uses can vary. My goal is to use a single unit object and modify its sprite and behavior based on its variables.
The challenge I’m facing is getting a unit to target another unit of the same type, but on a different team. I understand how to direct one object to another if they’re different, as I can just apply force from one to the other. However, I’m unsure how to do this when the objects are of the same type. Can anyone guide me on this?
Hello Eiklahc, thanks for taking your time to help.
What you’ve told me isn’t exactly what I’m looking for and I can’t tailor your answer to my need, let me try to explain better.
I’ll be having several teams in the autobattler, depending on the stage it can go from 2 teams to 16 teams, I’m not sure if using a scene variable the way you told me is going to work for what I want to do, since I wouldn’t be having a single target each time, but several targets, for all the teams.
Initially, I considered assigning a variable to each object to identify its target. However, I’m unclear on how to reference a second instance of the same object while executing a “Repeat for each instance of unit_object”.
This is what I want, but with many units inside many teams.
I only used the scene variable for the target x/y to make the example quicker. You can instead just store it on the object. So you would have a ‘self’ variable with a child of ID and Team and a ‘target’ variable with a child of ID and Team.
That would allow you to loop through each object and ‘filter’ each team, id and their target.
I still think having just a single object for each team would be much easier to manage, but it’s your project afterall
I agree with everyone else. If you use the same object you’re going to be continuously storing locations and switching between instances.
If you use separate objects then you can target them directly. And more easily use for each events.
You can still simplify certain things by putting objects into a group. You would then reference them with a group name but they would be separate objects that you could pick simultaneously while still filtering them with conditions like an object variable.
Thanks for the tip and insight, I do have other plans which in my mind using a single object will end up being better, in the future if necessary I’ll change to multiple units and groups, but right now I want to experience first hand the pros and cons of using this method.
MrMen and Eiklahc. Thanks for the help, you’ve been helping me a lot.
I think I understand, so a variable for themselves and another for the target, with child variables that contains additional information.
My struggle is how do I then search for the enemies information and place those informations inside the original object? If I do a “Repeat for each instance of Unit” everything after that will reference the current unit from the loop, right? For example, if I do this:
The first subevent then selects all the DinoDoux objects that are not on the same team as the one being iterated over. The scope of the pick all objects is only for that subevent (and any of it’s child/subevents).
The second subevent gets the co-ordinates of the target of the DinoDoux being iterated over.
The final subevent moves the DinoDoux being iterated over towards it’s target. Note that the select all objects of the previous 2 subevents do not apply here because of the scope of those conditions.
(Just crossed my mind that it makes no sense to post a still image, but well…)
Most of them are going to their closest target, but some aren’t, for some reason (I’m guessing it is because of the order of “Pick all”?). Still, that is good enough, I should be able to tinker with it better now.
Kudos to everyone. Nice code. One idea. Where you’re picking the nearest object and checking the id, i think you need to reverse those 2 conditions.
If you don’t filter out the id first then it could be picked as the nearest object but then when the id was checked then nothing would happen if the id was equal. Where as if you reversed the conditions and removed the id first from the pool of objects then it would always pick a valid object.
Wanted to check here and see if anyone would reply on this thread before I make a new one.
Why do you pick scene variable instead of object variable? If I change an object variable does that change it for each instance on the screen?
I am slowly working on an Ogre Battle type game but you control a player character. There will be 5 characters on each team and right now I just want 2 teams. When I implement something similar to what you guys have my test units just look at each other and don’t fire.
Hmmm. In the meantime I wonder if youtube will have a video pertaining to this.
You can not use an action in one instance of an object
to refer to a different instance of the same object,
because object picking will not allow you to do that,
scene variables act as a middleman
because they are not linked to a specific object,
so there must be no issues accessing them.
When you set an object variable it changes all of the currently “picked” matching instances. Objects get “picked” through condition(s) such as collision, ray cast, mouse pressed, etc. Pretty much any condition that references the object.
If an event doesn’t have any conditions then the variable is set for each instance of the referenced object.
Edit: on the object setting screen, you can add variables and set a default value for all of the instances. In the setting screen for instance where you set positions and things, you can set the the value of variables at an individual instance level.
I need to spend more time with variables and understanding them better I think.
I am actually unsure of what all variables I need to have assigned where, when I check over the things in the original post I didn’t see much about object variables at all. Should I have each variable in on all objects as well as scene?
My thought process is I need the units to be customizable with stat adjusters (equipment / level ups). The characters will have more than likely floating attach points for the most part. Not sure if I am going to do arms and legs but will eventually have Head, shoulders, back and weapon(s) attachment points for the units.
I would like to be able to have more than 2 teams. Eventually I would like certain events to take place where there is at least a 3rd party that battles both of the original teams. However if I can scale it up to like 5 groups of 5 units going at it that would be best.
I would like to do almost like a season in a sports game. So character management will be a big focus in another scene.
I plan on having dialogue with the characters that are based on their current stats, so eventually this will need to be able to pull in data from global variables. They will also take into account other global stats as well when engaging with the player.
If I could, it would be amazing to be able track who the characters killed and what team they belonged to.
I unfortunately don’t get to spend as much time as I would like exploring this engine so any tips are great. I’m currently utilizing the guide and some youtube tutorials, but any advice is welcomed.
In an effort to combine another element that I enjoy I want to eventually incorporate 4x overworld map features. This battler portion will be the action portion of the game. While the 4x portion will be akin to First Generation Total War Games.