Rebuilding scene in Adventure Creator
When your scene is ready, you can export all game objects as prefabs and rebuild the scene for your game.
Let’s take the Demo PAINTING multilevel scene as an example.
First of all click on the Save scene data button in the Scene tab.
In the 2.5dToolKit/25dTKTools/Scene data folder will be create a folder with the same name as the scene. Inside you will find the Resources folder which contains a text file with scene and character settings. This file is loaded when the game runs.
Now create the mesh. Move to the Mesh tab and drag VBAreaTK, child of VB25dTK, into the Areas field. Click Create mesh then Save mesh.
Move to the Advanced tab, select Export objects and click Save.
All game objects, the Main Camera, the Background Camera, the character will be saved in the same folder as prefab. Unused scripts will be removed from game objects and character, and the character movement script will be added. This script will read the data contained in the Resources folder. In perspective projection only the data relating to the walking and running speed you have set, in orthographic projection also the data for its scaling and for the change in speed as it moves away.
Scripts that use this data file are:
in the 2.5dToolKit/Demo/Scripts folder
in the 2.5dToolKit/25dTKTools/Scripts/External use.
The first two are attached to the character during its initialization in 2.5dToolKit, the second when you export the objects by selecting Export objects.
Now you have all the tools to recreate the scene for your game. Some of this data will not be necessary if you are using assets for adventure game creation.
See this page to set up a new scene without using dedicated assets.
Set up Adventure Creator
There are two ways to set Adventure Creator with the data exported by 2.5D Toolkit. We will both see them.
Create a new game using the New Game Wizard option. Set 2.5D perspective and select I’ll work with one background per scene.
This is not an AC tutorial so I will skip some steps assuming you already know how to work with it.
Create a new 2.5D GameCamera and from the Graphics folder of the PAINTING Demo (3 level) assign the BgMultiLevel background image. Set as active.
In the saved data folder you will find the text file [scene name] (data).
Set the 2.5D GameCamera to the saved position and rotation of the Main Camera. Also assign the FOV.
In AC’s Scene tab set Pathfinding method to Mesh Collider.
Create a new AC NavMesh. Drag the [scene name].asset from the Mesh folder into the Mesh field of the Mesh Collider. Deselect in the Navigation Mesh Script Ignore Collision. Adjust position and rotation to zero.
The mesh will appear exactly where it needs to be.
Drag the new AC NavMesh from the hierarchy into the Default NavMesh field.
Now drag the character into the scene from the Character folder. Remove Nav Mesh Agent and CharMovePersp script from it. Use AC’s Character wizard to initialize the character.
Adjust Capsule Collider and set the parameters as recommended in the Adventure Creator: Creating a 2.5D game Tutorial video in the Creating a Player section.
In the 2.5dToolKit/Demo/Controller folder you will find the SimpleAnimBlendTree controller. Assign it to the character and check the Apply Root Motion option.
Give PlayerStart the same position as the character.
From the Game Items folder drags all the prefabs into the scene.
If you now enter Play Mode, you can move the character in the scene.
However, you will notice that the character falls from the edges of the mesh.
You can look for a way to correct this unwanted behavior or use an alternative solution.
Set Pathfinding Method to Unity Navigation. Drag the prefab of the mesh from the Mesh folder into the scene. Select the mesh and from the 2.5dToolKit/Shading folder drag the MatteShadow material into the Mesh Renderer material and the CustomTransparentShadowCollectorVal shader into the mesh Shader field. See here for detailed information.
Assign the NavMesh layer to the mesh and bake it adjusting the parameters.
Now enter Play Mode, click to move the character and fix parameters such as acceleration, turn speed etc.
Walking in place
In some cases it may happen that the character stops moving when walking in place. Some mesh vertices may conflict with the AC character movement script.
In this case you can proceed like this:
Add Nav Mesh Agent and AC’s NavMeshAgent Integration component to the character. Select Use AC For SpeedValues.
Add 2.5dTK’s CharMovePersp script.
Change the Controller with AnimCtrl25dTK found in the 2.5dToolKit/Demo/Controller folder and set Motion control to Manual, which you find in the AC Player script, in the Animation section..
Look in the data file found in the Resources folder that is loaded when the game starts (when you are not using assets for adventure game creation. This file is loaded by the CharMovePersp or CharMoveOrtho script.).
Identify the movement parameters as in the figure:
300 and 1500 are the values for rotation speed in walking and running.
1.5 the walking speed at the closest point and 1 at the farthest point. Since we work in perspective projection the value at the farthest point will be ignored. It is only useful in orthogonal projection.
Same thing for the next two values for the running.
So the two values we need are 1.5 for walking, and 4.2 for running.
Enter these values in the AC player script, in the Movement section, in the Walk speed scale and Run speed scale fields.
The character will now no longer stop unexpectedly. Play with the other parameters to improve the movement.
If character rotates while walking or idle, play with Freeze Position and Freeze Rotation in Rigidbody.
the character has a simple attached script, HideTopStairsSprite, who hides or shows the sprite of the upper staircase according to the position of the character. This is because in some cases the sprite could be in front of the character and therefore hide it for a few seconds.