Hi, I am new to Unreal Engine. I have issue with play replay using C++ code. I use the ThirdPerson template to create a C++ project, and add my custom replay code as below:
void AReplayTestCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{
//......
PlayerInputComponent->BindAction("RecordReplay", IE_Pressed, this, &AReplayTestCharacter::StartRecordReplay);
PlayerInputComponent->BindAction("PlayReplay", IE_Pressed, this, &AReplayTestCharacter::StartPlayReplay);
}
void AReplayTestCharacter::StartRecordReplay() {
if (IsRecordReplay) {
IsRecordReplay = false;
GetWorld()->GetGameInstance()->StopRecordingReplay();
} else {
IsRecordReplay = true;
GetWorld()->GetGameInstance()->StartRecordingReplay(TEXT("TEST"), TEXT("TEST"));
}
}
void AReplayTestCharacter::StartPlayReplay() {
GetWorld()->GetGameInstance()->PlayReplay(TEXT("TEST"));
}
I press the “RecordReplay” button twice for start and stop record, and then press the “StartPlayReplay” button, but no replay start, and the viewing camera changed to a very strange position.
And I tested a few things more:
- Use command of “demorec TEST”, “demostop”, “demoplay TEST”, its working.
- Use command of “demorec TEST”, “demostop” and press “StartPlayReplay” button, its not working.
- Press button “RecordReplay” button twice and use command “demoplay TEST”, its working.
- I also tested in UE 4.14, its not working as well.
Its really helpful for having this replay system, but I want to achieve this functionality using C++ code, any help would be very grateful. Thanks in advance!