I have been tinkering with creating a combatant using script. It worked, and I can make the combatant appear in a specific location on a scene.
My questions are: - how can I create a number of combatants, and then assign them to different parties / player group? So let's say I have created combatants A,B,C,D,E,F. A,B go to group 1, C,D go to group 2, and E,F go to group 3. - After the groups are all set, how do I make sure that when I save the game (by clicking on the save game menu), all the above combatants info (health, position, etc) and their group configurations are also saved into the savegame file? Will ORK by default recognize all these script generated combatants?
Group group = ORK.Game.PlayerHandler.GetGroup(1); group.Join(0); group.Join(1); ...
You can also do this through the event system - in that case, you'll first need to create a new group using the Create Group step, and switch the active player group to that group using the Change Active Group step. After that, you can join combatants using the Join Active Group step.
All player groups and their combatants will be saved in a save game, it doesn't matter if they're coming from an event or a script, when they're added, they're saved :)
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
The player groups are managed by the PlayerHandler class - you can access it through:
ORK.Game.PlayerHandler
Player groups are identified by an ID - the default group (which is already created at game start) has the ID 0.
The following function will return you a Group object for an ID, if the group doesn't exist, it'll be created:
ORK.Game.PlayerHandler.GetGroup(int id);
You can join combatants to the group, either through their ID (index) or using a combatant object:
group.Join(int id);
group.Join(Combatant combatant);
So, in total:
Group group = ORK.Game.PlayerHandler.GetGroup(1);
group.Join(0);
group.Join(1);
...
You can also do this through the event system - in that case, you'll first need to create a new group using the Create Group step, and switch the active player group to that group using the Change Active Group step.
After that, you can join combatants using the Join Active Group step.
All player groups and their combatants will be saved in a save game, it doesn't matter if they're coming from an event or a script, when they're added, they're saved :)
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I tried with one combatant, and I can spawn him on a specific location.
However, when I tried to add him to a group, he disappears.
follow-up question: how do I spawn the new player group at a specific location or to get one of the group members location and use it?
You can spawn a new player group by first spawning it's leader and spawning the other members afterwards.
Spawning a group's leader:
group.Leader.Spawn(Vector3 position, bool setRotation, float yRotation, bool setScale, Vector3 scale);
Spawning the rest (battle group only):
group.SpawnGroup(bool onlyNonCreated);
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!