Announcement

Collapse
No announcement yet.

Local Multiplayer Class Spawner

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Local Multiplayer Class Spawner

    I apologize if this has already been answered, I did a bit of searching and couldn't find a working solution.

    I have a class called AJGeneric that derives from BasePony. Right now, in my gamemode stg_battle.cpp, I have:

    Code:
    DefaultPawnClass = AAJGeneric::StaticClass();
    This works for spawning 1 player. However, default isn't going to work in this case, as we need to spawn up to 4 players. I tried this:

    Code:
    GEngine->GameViewport->CreateLocalPlayer(0, FString("Error."), true);
    Obviously, I have no idea what that bit of code does. I also tried:

    Code:
    void Astg_battle::BeginPlay() {
    	Super::BeginPlay();
    	UWorld* const World = GetWorld();
    
    	if (World){
    		World->SpawnActor<AAJGeneric>(AAJGeneric::StaticClass());
    	}
    }
    Which did nothing but spawn a broken AJGeneric class.

    What is the best way to spawn in players by code?
Working...
X