Download

mudar de umg

como mudo de widget via codigo quando carrego num botão options
o meu jogo crash
o que estou a fazer mal
estou a usar este tuturial para fazer o meu sistema de login
https://www.youtube.com/watch?v=W-xW0epcPVA



void ULoginMenuWidget::OnOptionsClicked()
{

if (GetWorld()->GetGameInstance())
{
UStateManager *StateManager = Cast<UStateManager>(GetWorld()->GetGameInstance());
if (StateManager)
{ StateManager->ChangeState(EGameState::EOptionsScreen);
}
}
/*
if (GEngine) {
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::MakeRandomColor(), TEXT("Options"));
}
/**/

}

como é que mudo de menu principal para o jogo quando carrego no butão login em c++
eu pus o codigo no dropbox segue-se o link
Dropbox - File Deleted

pelo visto vc n tem referencia alguma do widget q quer que apareça, se vc n tem experiencia em c++ sugiro esquecer por agora, faça o mesmo em BP, aprenda e mais tarde pula pro c++.
Se for fazer em BP, sugiro usar o game instance para criar ambos os widgets e suas referencias, use custom events para criar os widgets, adicionar ou removê-los da tela. Quando quer mudar de um para outro, basta entao pegar a referencia do game instance e chamar os eventos de acordo, fica correto e limpo.
Boa sorte

ja descobri o problema
bastei referenciar na blueprint

pois mas agora veio outro problema
quando saio do jogo e volto a tentar a fazer login pela segunda vez o jogo crasha
vai o link para o meu projecto
o que estou a fazer errado


Access violation - code c0000005 (first/second chance not available)

UE4Editor_CoreUObject
UE4Editor_RPG_4849!UGameSparksStatics::LoginSucessDetails_Response() [c:\users\pedro\documents\unreal projects\rpg\source\rpg\gamesparksstatics.cpp:48]
UE4Editor_RPG_4849!GameSparks::Core::GSTypedRequest<GameSparks::Api::Requests::AccountDetailsRequest,GameSparks::Api::Responses::AccountDetailsResponse>::Callbacks::OnSucess() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\include\gamesparks\gstypedrequest.h:113]
UE4Editor_GameSparks!GameSparks::Core::GSRequest::Complete() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gsrequest.cpp:83]
UE4Editor_GameSparks!GameSparks::Core::GS::ProcessReceivedResponse() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gs.cpp:510]
UE4Editor_GameSparks!GameSparks::Core::GS::ProcessReceivedItem() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gs.cpp:565]
UE4Editor_GameSparks!GameSparks::Core::GS::OnMessageReceived() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gs.cpp:164]
UE4Editor_GameSparks!GameSparks::Core::GSConnection::OnWebSocketCallback() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gsconnection.cpp:129]
UE4Editor_GameSparks!`anonymous namespace'::_RealWebSocket::_dispatch() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\easywsclient\easywsclient.cpp:649]
UE4Editor_GameSparks!GameSparks::Core::GSConnection::Update() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gsconnection.cpp:160]
UE4Editor_GameSparks!GameSparks::Core::GS::UpdateConnections() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gs.cpp:314]
UE4Editor_GameSparks!UGameSparksModule::Tick() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparks\private\gamesparksmodule.cpp:66]
UE4Editor_Engine
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
kernel32
ntdll 

acho que problema esta nesta linha de codigo



void UGameSparksStatics::LoginSucessDetails_Response(GameSparks::Core::GS & gs, const GameSparks::Api::Responses::AccountDetailsResponse & resp)
{
	if (inicialized) {
		if (!resp.GetHasErrors()) {

			/***********************************************************************/
			if (theWorld->GetGameInstance())
			{
				UStateManager *manager = Cast<UStateManager>(theWorld->GetGameInstance());   
				if (manager)
				{
					manager->ChangeState(EGameState::EServerScreen);
				}


			}
/****************************************************************************************/
			else
			{
				if (GEngine) {
					GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::MakeRandomColor(), TEXT("Accounts Details Request Fail"));
				}
			}

		}


	}
}

porque por o codigo assim como esta em baixo funciona bem


void UGameSparksStatics::LoginSucessDetails_Response(GameSparks::Core::GS & gs, const GameSparks::Api::Responses::AccountDetailsResponse & resp)
{
	if (inicialized) {
		if (!resp.GetHasErrors()) {
			if (GEngine) {
			GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::MakeRandomColor(),resp.GetJSONString().c_str());

			}
			else
			{
				if (GEngine) {
					GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::MakeRandomColor(), TEXT("Accounts Details Request Fail"));
				}
			}

		}


	}
}