Turn-based RPG system (with separate overworld and battle system)

Advertisemen

The past few days, due to playing Persona 5, I've been contemplating how to go about implemented a system in Unreal Engine where the main game takes place in an overworld (third person view). Think an RPG where you walk around talk to people and explore stuff, and you can encounter enemies. When you encounter an enemy you switch from this overworld to a battle state. This battle state is completely different in appearance and behaviour from the overworld, it's almost like a different game (think of the Pokemon games: walking around vs. the turn-based battling).

A fair assumption would be:


Let's fully define the overworld and battle system with examples from Persona 5. In Persona 5, the overworld looks like this:


And the battle system looks like this:


The only thing that is really shared between the scenes are the character models (well, actually in this case the characters wear different clothing in the battle from the overworld but that's adding way too much complexity at this early stage). But we can say, that if the style and models were replaced in the battle system you would be hard-pressed to see any similarity between the two considering the gameplay is entirely different.

I've implemented such systems before in programming language only engines (i.e. LibGDX) where you simply have a state determining whether you are in the overworld or battle system and update logic/render accordingly:

if (GameState == OVERWORLD) {
updateOverworldLogic();
renderOverworld();
} else if (GameState == BATTLE) {
updateBattle();
renderBattle();
}

The difficulty here is from the layout of modern day engines such as Unity or Unreal in that the game is not solely defined in the code, there is the WYSIWYG editor which contain lots of components (Unity: GameObjects, Unreal: Actors), which each may or may not contain some attached behaviour defined in code.

This means that the above example of a simple state check is implausible as there is no one global area to do this.

My initial thinking about this idea led me to two possible solutions (UE in particular, may be similar for Unity):

Idea 1: State Manager
Create a State Manager actor in your scene. The idea behind this actor is to manage the Overworld and Battle states (and potentially any additional states if there is the need), and update the scene according. Since the game starts off in the overworld at this point the State Manager can be ignored entirely. It is required the moment you encounter an enemy and the state needs to switched in the Battle state.

For this to work, all the actors in the Overworld needs to have a tag titled "Overworld", this will then allow the State Manager to iterate through all the Overworld actors and freeze their behaviour, potentially with the SetCustomTimeDilation function or the SetActorTickEnabled function.
Once that is done, then either the Battle actors can be spawned (or unfrozen if they already exist). To handle the different inputs and control systems, we will require a second PlayerController specifically for the battle.

On completion of the battle,  switch the player controller back, delete/freeze the Battle actors, unfreeze the Overworld actors and continue the game from the Overworld.
Repeat everytime a battle happens.

Idea 2: Scene Serialisation
Serialise and save the overworld scene, load a new scene specifically for the battle, handle that. Then on the completion of the battle load the serialised overworld scene and continue. This seems like it could incur massive load times depending on how big the overworld scene is. Especially if it was an open world game (think of the long loading times of The Witcher 3 and Horizon: Zero Dawn).

---

Personally I think I will go with the first solution as it would be possible to do seamless transitions between the overworld and the battle.

Advertisemen

Disclaimer: Gambar, artikel ataupun video yang ada di web ini terkadang berasal dari berbagai sumber media lain. Hak Cipta sepenuhnya dipegang oleh sumber tersebut. Jika ada masalah terkait hal ini, Anda dapat menghubungi kami disini.

Tidak ada komentar:

Posting Komentar

© Copyright 2017 Game Engine Tutorial