Level Start -> object creation

Hey,

I have following problem/question:

Lets say I want to create a object when my Level starts. Where would I do this?
Where are actually the PlayerCharacters created?
What if I want my PlayerCharacter to be created after a button click or something.

Right now I have no idea how I would do all these things, using the existing code.

First of all, here is your new bible:

Use it to search what you need

Now on specific problem, UE4 has it’s own respawn system, you can set up default pawn (base class of character class, character is just extended pawn) for players:

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AGameMode/DefaultPawnClass/index.html

And GameMode class should automaticly spawn them in PlayerStart… if not you can use this function to spawn them:

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AGameMode/SpawnDefaultPawnFor/index.html

If this system does not fit you need spawn player chatacter on BeginPlay() (every actor class have this event) using ()->SpawnActor(ASomeActor::StaticClass()); then you make playercontroller posses it. I think PlayerController is best place for such code.

Also heres link for gameplay framework documentation which you should find useful:

thanks for your answer!:
few other questions:

I think the ue4 Character get spawned with this code on the GameMode class?:

static ConstructorHelpers::FObjectFinder<UClass> PlayerPawnBPClass(TEXT("Class'/Game/Blueprints/MyCharacter.MyCharacter_C'"));
	if (PlayerPawnBPClass.Object != NULL)
	{
		DefaultPawnClass = PlayerPawnBPClass.Object;
	}

Is it recommended to use GameMode as Level start?
Let say I want to create a player and automatically add this player to a team or something or setting up a point system, should this be done in the GameMode?

GameMode class
{
  ..SpawnActor..
  addPlayerToTeam(actor);
  PointSystem pt;
}

If it’s somehow possible to get the spawned actor…

It really does not matter, if you feel comfy with gamemode then go for it

ok thanks!

talking about the player controller.
In a lot of thread and tutorials I se this player controller.
My question is: Is this controller automatically created?
Or do I have to create it myself?

(because I can’t find it)

ITs created by already existing classes, created for each player in game

ok, found it in the Scene Outliner when I press “Play” in the editor. Seems like the Counter increases each time I hit “Play” (e.g PlayerController1 → PlayerController2 → PlayerController3)

Another question:
Went through some Links you’ve posted, but found no answer to this:

When I hit “Play” my default ue4 Character is created with this code:

static ConstructorHelpers::FObjectFinder<UClass> PlayerPawnBPClass(TEXT("Class'/Game/Blueprints/MyCharacter.MyCharacter_C'"));
if (PlayerPawnBPClass.Object != NULL)
{
	DefaultPawnClass = PlayerPawnBPClass.Object;
}

My problem right now is, how do I get its Actor out of there?
Because I would need the Playercharacters Actor to add it to a TArray at start.

I thought the solution is the DefaultPawnClass, and get it from there, but didn’t work.

created a seperat thread for this specific question: