-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Team switching with units pre-placed in world #156
Comments
Hey @DertyMunke! Can you share a few more details about your setup?
|
Hello @npruehs,
I used your example project to start with. I removed the AI player, moved
the Player Start's farther away from each other, and placed a building in
the scene for each player, next to the Player Starts, near where the unit
spawns. I set the buildings to "CONSTRUCTIONSTATE Finished" and I set
Unreal to 2 players and "Play as Listen Server." It works correctly when
the server is player index 0, but when the server is player index 1, the
buildings are associated with the wrong player.
|
Hey @DertyMunke! Sorry, I'm afraid properly assigning pre-placed units to players isn't implemented yet - or, more specifically: Assigning fixed player starts to players isn't implemented yet. While you can specify which units should be owned by which player, there's currently no way of telling a player to always spawn at a specific player start. We had some solution in place for A Year Of Rain, but I'm not too satisfied with the results. Things got pretty messy, trying to support three different game modes, PvP, Coop campaign and a third team-based game mode, all at the same time. Thus, that solution has never been merged back. |
Hey @npruehs, I thought setting the "Team Index" of the "Player Start" to the same number as the "Initial Owner Player Index" of the unit placed in scene would make the unit on the same team as that "Player Start." I just need the unit to be spawned on the left of one player start and to the right of the other for symmetry and fairness to the players. Do you have any suggestions on how to achieve that, or is it time for me to start diving into the code? If code, do you know off hand which class is most likely to handle this behavior or where is a good place to begin the dissection? |
Team index and player index are two different things. Depending on your game, you might create a 2v2 game mode for instance, with player index [0..3] and just team index 0 and 1 available. With being able to assign player owners to pre-placed units through setting the InitialOwnerPlayerIndex of your RTSOwnerComponents, the key is just to make sure that the player with the correct index spawns at the correct player start. As you've already noticed, right now, player starts just feature a team index. So, to achieve what you're trying to do, you probably want to add a Player Index to the player starts, and then change ARTSGameMode::RestartPlayerAtPlayerStart to assign the player index of each player accordingly. The current implementation calls GetAvailablePlayerIndex to find any player index that's not in use, but you'll probably want to use the one matching your player start instead. |
I have 2 player starts with team index 0 and 1. A vehicle spawns next to its headquarters when the game starts, but if the server spawns on team index 1, then the headquarters are on the wrong teams. I've set the headquarters owner->team index to the corresponding player start team index, but either the player start or the headquarters is changing its associated team. Everything works as expected when the player spawns at the Player Start with index 0, however.
The text was updated successfully, but these errors were encountered: