Skip to content
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

Open
DertyMunky opened this issue Apr 20, 2021 · 5 comments
Open

Team switching with units pre-placed in world #156

DertyMunky opened this issue Apr 20, 2021 · 5 comments
Assignees
Labels

Comments

@DertyMunky
Copy link

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.

@npruehs
Copy link
Owner

npruehs commented Apr 20, 2021

Hey @DertyMunke!

Can you share a few more details about your setup?

  • Is your headquarters pre-placed in the level?
  • How do you spawn your vehicle?

@npruehs npruehs self-assigned this Apr 20, 2021
@npruehs npruehs added the bug label Apr 20, 2021
@DertyMunky
Copy link
Author

DertyMunky commented Apr 20, 2021 via email

@npruehs
Copy link
Owner

npruehs commented Apr 25, 2021

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.

@npruehs npruehs added feature and removed bug labels Apr 25, 2021
@DertyMunky
Copy link
Author

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?

@npruehs
Copy link
Owner

npruehs commented Apr 27, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants