Page 1 of 1

Load new level in Game Launcher

Posted: Thu Jul 18, 2019 9:11 am
by hodirt
I load my start level in Game Launcher like

Code: Select all

gEnv->pConsole->ExecuteString("map First_Level", false, true);
All is fine.
But then, on some point I want to load the next level, doing the same thing

Code: Select all

gEnv->pConsole->ExecuteString("map Second_Level", false, true);
and game craches. Log provides only this little information
<12:08:57> [CONSOLE] Executing console command 'map Second_Level'
<12:08:57> ============================ Loading level Second_Level ============================
<12:08:57> Ending game context...
<12:08:57> Destroying CActionGame instance 0000013EC9FFBA50 (level="First_Level")
<12:08:57> UnLoadLevel StartCritical error detected c0000374
How this can be solved?

Re: Load new level in Game Launcher

Posted: Fri Jul 19, 2019 1:14 am
by dignity
You mentioned that you use the launcher (pure game mode). This requires that you have exported your level from the sandbox editor to the engine. Did you do this? As far as I remember correctly the shortcut for this in the editor is F7. Or you just click File->Export to Engine.

- Jannis

Re: Load new level in Game Launcher

Posted: Fri Jul 19, 2019 9:17 am
by hodirt
Yes, I've exported both levels to the engine

Re: Load new level in Game Launcher

Posted: Sat Jul 20, 2019 3:08 am
by dignity
You could try first if it works with Flowgraph. Inside the „Mission“ nodes you‘ll find the Node „LodNextLevel“. Just try if this node works (does not work inside of editor). If it works, then you can use it‘s code here: https://github.com/CRYTEK/CRYENGINE/blo ... nNodes.cpp

It uses the ScheduleEndLevel function of CCryAction (by the way: if you type gEnv->pGameFramework... this is actually the CCryAction instance). You can see the definition of this function here:
https://github.com/CRYTEK/CRYENGINE/blo ... ryAction.h
Line 216. There is also on line 217 the function ScheduleEndLevelNow.

So basically what you can try ist this:
gEnv->pGameFramework->ScheduleEndLevel(„Second_Level“);

If this code does not work, but the FlowNode works (which uses the same piece of code), then you have pretty likely a bug somewhere else.

- Jannis

Re: Load new level in Game Launcher

Posted: Sat Jul 20, 2019 7:26 am
by hodirt
I tried this node and it gives the same result. But it didn't work in my project with lots of code and logic (even in empty levels). In new plain project it works just fine.
Trying to find, what may cause that error

Re: Load new level in Game Launcher

Posted: Sat Jul 20, 2019 9:48 am
by hodirt
So, exception occurs here

Image

And, sadly, a have no idea, because of what it happens

Re: Load new level in Game Launcher

Posted: Sat Jul 20, 2019 10:46 am
by dignity
Ok. it seems to be more related to a bug in your code. You can try using the debugger to track it down. As you mentioned: it works fine inside of a new fresh project. So the problem doesn‘t seem to be related to the gEnv->pConsole->ExecuteString function.

- Jannis

Re: Load new level in Game Launcher

Posted: Wed Nov 06, 2019 1:19 pm
by kdnevan
replace with the name of your map level example:
my level is called "b1tch" then replace
gEnv->pConsole->ExecuteString("map b1tch", false, true);