Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

DemoPlay can't spawn custom spectator class


I'm on version: Version: 4.8.3-0+++depot+UE4-Releases+4.8 with the github source.

I reckon the demo (demorec, demoplay, etc) is still in it's infant's shoes.

I'm binding to the PostDemoPlay delegate like so:

 void UMyLocalPlayer::PostInitProperties()
     FCoreUObjectDelegates::PostDemoPlay.AddUObject(this, &UMyLocalPlayer::DemoStarted);

The difficulty here is that obviously the demoplay command doesn't allow specifying a custom playercontroller class. It simply spawns the PendingLevelPlayerControllerClass in ULocalPlayer::SpawnPlayActor(...) called from UWorld::LoadMap(...) (LoadMap is called by: UDemoNetDriver::InitConnectInternal(...)). Even though there exists a UDemoNetDriver::DemoSpectatorClass which can be specified via config, this is not used when setting up a demoplay PlayerController.

Now, trying to spawn my own MyPlayerController class after PostDemoPlay has been broadcasted, it simply fails because the UWorld I receive from ULocalPlayer::GetWorld() doesn't have a CurrentLevel:

 AActor* UWorld::SpawnActor( UClass* Class, FVector const* Location, FRotator const* Rotation, const FActorSpawnParameters& SpawnParameters )
     check( CurrentLevel );       // CurrentLevel is NULL here!!!
     check(GIsEditor || (CurrentLevel == PersistentLevel));


 void UMyLocalPlayer::DemoStarted()

yields the same error.

I currently find no way of spawning my own spectator PlayerController class in a demoplay environment.

According forum thread: https://forums.unrealengine.com/showthread.php?79867-Spawning-actor-during-demoplay

Product Version: UE 4.8
more ▼

asked Aug 11 '15 at 11:15 AM in Bug Reports

avatar image

91 14 13 22

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi Timoses,

It is possible to use your own PlayerController class for this, but it has to be known when the replay is recorded, so that an actor of this type can be spawned and recorded in the replay. Also, the way you specify this class has changed in 4.9.

In 4.9, you'll need to set the ReplaySpectatorPlayerControllerClass property on the GameMode class.

In 4.8, the class is set through the config property DemoSpectatorClass on UDemoNetDriver. You can add a line like the following to your DefaultEngine.ini file (this one is from ShooterGame):


ShooterGame uses a custom spectator controller for replays, so feel free to use it as an example!

more ▼

answered Aug 11 '15 at 08:01 PM

avatar image

Ryan Gerleve STAFF
1.1k 25 12 49

avatar image Timoses Aug 12 '15 at 12:21 AM

Ah, well that makes sense! Thanks a ton for your reply, Ryan. Really looking forward to the 4.9 version, especially in respect to https://answers.unrealengine.com/questions/260135/broadcasting-a-match-to-in-game-spectators.html .

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question