hey everyone. I have searched high and low for this on the web…
in Lyra … Can I set TEAM ID somehow? I get randomly assigned to be red or blue…
But if I always want to spawn as blue…?
I can’t find WHEN I’m getting assigned a team… Anyone knows?
here is a Lyra Team Creation Component but can’t set anything.
T
I was looking for a BP solution, but as you say, there isn’t any.
I ended up using my own teams system with gameplay tags instead
I also got this from the man himself Michael Noland (programmer for the Lyra project):
The teams are determined by the ULyraTeamCreationComponent subclass used in your experience, specifically the ServerChooseTeamForPlayer implementation.
By default this picks the team with the fewest players (via GetLeastPopulatedTeamID), but you can create a subclass to do whatever you want, e.g., map all humans to team 1 and all AI to team 2, or read some state from the player state indicating what team the player wants.
You’d have to make that subclass of the team creation component in C++ but you could expose functions to let you control how it works from BP in there.
ShooterGame’s experience is currently using B_TeamSetup_TwoTeams derived from LyraTeamCreationComponent.
I’m setting this as resolved.
But for all that read this and perhaps was searching for a BP solution:
There isn’t any.
I made the easy way by testing directly into the C++ file \Source\LyraGame\Teams\LyraTeamCreationComponent.cpp
and it works (1 human versus 3 bots)
void ULyraTeamCreationComponent::ServerChooseTeamForPlayer(ALyraPlayerState* PS)
{
if (PS->IsOnlyASpectator())
{
PS->SetGenericTeamId(FGenericTeamId::NoTeam);
}
else
{
int32 SelectedTeamID;
if (PS->IsABot()) { // If player is a bot then team red
SelectedTeamID= 1;
}
else { // If player is a human then team blue
SelectedTeamID= 0;
}
// const FGenericTeamId TeamID = IntegerToGenericTeamId(GetLeastPopulatedTeamID());
const FGenericTeamId TeamID = IntegerToGenericTeamId(SelectedTeamID);
PS->SetGenericTeamId(TeamID);
}
}
But anyone know a better example and can describe the good practice for a new instance class based on lyra plugins ?
Under LyraTeamSystem.h there is a public method not exposed to Blueprint
// Changes the team associated with this actor if possible
// Note: This function can only be called on the authority
bool ChangeTeamForActor(AActor* ActorToChange, int32 NewTeamId);
I’m checking to see what happens if I update to this:
// Changes the team associated with this actor if possible
// Note: This function can only be called on the authority
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = Teams, meta = (Keywords = "Set"))
bool ChangeTeamForActor(AActor* ActorToChange, int32 NewTeamId);`
Edit: This works! I was able to add a new blueprint that lets me change teams.
Hi,
this may be caused by an update, but Team One (Red) is no longer GenericTeamID “0” but “1” and Team Two (Blue) is “2” . If you set it to zero, it messes up the team creation.
Hi . Im currently wanting to do this with a non C++ solution.
As was wondering If anyone knew which BP the teams are actually being set by the lyra subsystem. So I could just disconnected that part and Come up with my own team selection code?.
Also TBH Im confused as to why this option is not even exposed to begin with as its such an important option for anyone wanting to build a multiplayer game on lyra.
Thanks. I resorted to c++ methods. Took me a while to get it right but With advice I managed to GET VS up and running. Now I just want to find a way to set team the from the UMG, team selection and Also traditional MP character class . I already got those menus ready But its a bit sketchy on which BP the UMG cast to to set them in.
Hey guys, I tried this using Unreal 5.1 and 5.3 - I exposed the Function as explained in LyraTeamSubsystem.h by changing it in a Text Editor:
// Changes the team associated with this actor if possible
// Note: This function can only be called on the authority
UFUNCTION(BlueprintCallable, BlueprintPure=false, Category=Teams, meta=(Keywords="Set"))
bool ChangeTeamForActor(AActor* ActorToChange, int32 NewTeamId);
Anyways I can not get it in the Blueprint - what part am I missing here? I would like to recreate the above shown, but in my B_Hero_ShooterMannequin Blueprint I can not create the "Change Team for Actor " function even so I changed that tiny bit of code in the .h file?