Scene searching tab


First of all

If you use your own character, follow the instructions below.

It must have only two components:

Animator, with AnimCtrl25dTK as controller and Apply Root Motion unchecked.

Nav Mesh Agent, with the Height value set according to its height.

This new tool is very useful for automatically finding camera settings for a 2D image.

However, it is a good idea to specify some details about the search scripts. They are based on some parameters set by the user. The final result will be a certain number of environments that correspond to the parameters entered. 

This method has important strengths that make it preferable to a script that finds unique camera values returning only one environment.

The reason is simple to understand: let’s assume that the image is a photograph taken with a FOV of 60. By now we know well that 2.5D environments require a rather low FOV to avoid the annoying inclination of the character to the sides of the screen. If the script only returned the original values we would have to be satisfied with the final result: our character will scale correctly in its world compared to the objects around it, but with a high FOV we would have to keep its distortion.

With the 2.5d Toolkit search scripts we will instead have the possibility to test different environments with different FOVs and choose the one that meets our needs.

Later we will see the few steps required to set up the search, but first it is good to summarize them briefly.

Note: as evident, the search is only possible for perspective projection.

This is what we will have to do:
first, we will have to set the horizon line. It will have to be moved to the furthest point of the walking area that we plan to draw. If there are multiple walking areas in the scene, it will be the furthest one to take into consideration. In short, the furthest point our character will have to reach.

So we will draw a reference line, a line whose length we know or can guess at. This line is very important, because the whole world around it will be proportional to it.

Finally we will choose a point in the scene in which to set the character’s height, and to do this we can base ourselves on some object present in the scene. We still need to set the character’s height to a different point a second time, again based on some object.

All environments returned by the search will match these parameters. For each FOV value, between 60 and 5, if a corresponding scene exists, we will obtain one or more environments in which our line corresponds to the assigned value (in meters) and the character will move within the scene with the set proportions.

Once we have obtained the environments, our only job will be to analyze them to verify which of them meets our needs.

Our target is to find that scene in which the character walks along our line in a number of steps within a range suggested by the script. This is to make the environment as realistic as possible.

A script has also been provided for this step that speeds up this operation. We’ll see it shortly.

Note: There are three default search settings, from fastest to slowest, but each parameter is customizable. We’re about to see this too.

Let’s start with a demonstration. We will take the POOLS demo image as an example.

We leave the PPU at 100 and drag the Main Camera, the background image and the character into their fields.

We will get the initial scene:

Now let’s go to the main menu on the Scene searching tab.

We have the ability to activate contextual suggestions. It is advisable to activate them upon first use.

We initialize the script by clicking on Initialize searching. A popup will warn you that the scene is about to be set to default values.

The camera will be set with a FOV of 5, a minimum height, and a rotation that moves the horizon line to the highest point of the image. We decided to start with the minimum FOV, precisely because, as mentioned, we will not have distortions of the character if we were to set it very close to one of the two sides of the image.

The Set horizon option appears on the right. We set it as anticipated in the summary at the furthest point of the walkable area that we will draw later.

In the case of this image, our area will end where the wall of the house begins.

Now click on Done. The new Draw reference line option will appear.

We click New line.

We have entered the drawing mode. We draw a line for which we know the length or can hypothesize it.

If you can, stay a little detached from the extreme edges of the image because in the following tests the character will walk along this line and you will be able to count the steps more easily.

As you can see a new option has appeared: Assign a length to the line. As already mentioned this measurement is very important because the world will be based on this length. 10 meters might be a likely length.

Type the measurement in the field and the last option will appear: Set character size in two different points.

We click Begin resizing.

The character will be placed in the scene and controls for scaling it will appear.

In the case of this image we don’t have a good reference point to set its height at the point closest to us, so we will have to assume it. We drag the character to a point that is convenient for us and set its height.

Keep in mind that we are working with a FOV of 5, so resizing the character will require the maximum Scale accuracy when it is close to us and the minimum at the furthest point. Otherwise the character would change size too quickly or too slowly.

Once we have the right size we click on Store 1st point.

Let’s now move the character to the furthest point or wherever is convenient for us to assign a second dimension to it. For this image we can use the door at the bottom right as a reference.

Consider that there is a step in front of the door, so we need to keep the character’s height a little lower than the highest point of the door.

We click on Store 2nd point.

Our character will return to the starting point and it will not be possible to move it at the moment unless by clicking on the Goto the near point or Goto the far point buttons.

The search configuration options will appear at this point.

We can choose between three predefined settings: Less accurate, Medium accurate, Very accurate. Whatever the choice, the options can be customized. At the bottom of this page, but also in the asset’s 2Dto3D folder you will find a legend that explains the various parameters.

The suggestion is not to touch any settings and start the search with the default parameters. Only if the search produces zero results, and this can generally only happen if the length assigned to the line or the two dimensions of the character are not consistent with the environment, can the settings be adjusted.

Naturally you can change your initial search settings without starting from scratch, but if for example you want to redraw the reference line the character settings will also have to be re-entered.

Now that we have set the search parameters, click on Start searching.

A progress bar will indicate the progress of the search and a brief summary will inform you of the environments found. If you have not adjusted the default parameters it will not take long depending on the configuration of your PC. A few minutes, even less.

During the search you will only see the background image, everything else will be hidden.

Remember not to move the focus to other windows, as the search may pause, nor to select objects in the hierarchy, as the search may slow down.

This is the result of our research:

For a good number of different FOVs one environment was found, in two cases two environments.

Keep in mind that if the script finds two or more environments that are very similar to each other, it will memorize the one where the character has the smallest height difference in the two points indicated. This is the reason for the two entries in Character range, Found and Best values stored.

Let’s try to understand the results opening some of them..

With a FOV of 30, our reference line measures approximately 10 meters. We left the default setting, which states that the line can be 10% shorter or longer. That is, 9 to 11 meters.

For the environment to be memorized, the character must have a difference in height, at the closest point and at the farthest point, equal to or less than the set value of 0.1. Normally 0.1 is an acceptable value, but if you want, you can make the search even more precise by lowering this value, or even the percentage range of the reference line.

The height of the camera is 2.68 and its rotation 9.7.

With the FOV at 25 there are two environments found, both with the Y axis of the camera at 2.68 but with different rotation, 8.1 and 9.1.

With the FOV at 13 we have a camera positioned in height at 1.68 and a rotation at 4.8.

We can click on the link of the environments found to set the camera values to the scene and drag the character with the right mouse button to verify that it keep the assigned proportions. Alternatively we can click on the two buttons Goto the near point and Goto the far point.

Important: depending on various factors, general settings, camera distance, rotation etc, the height of the character at the furthest point may vary slightly. Indeed the difference between the two dimensions is always 0.1 or less than 0.1, but visibly it might seem a little higher. Then choose the configuration that best respects the desired proportions.

Note: some configurations may offer the same number of steps. In this case we can choose the one we like best.

As we can imagine, according to the FOV and the rotation of the camera our character will take more or fewer steps to travel the 10 meters assigned to the reference line. We need a scene that does not have a high FOV but at the same time allows our character to travel the test line with the right number of steps.

Since the character’s speed varies according to the scene and must be set manually, testing 23 scenes would take some time. For this reason, a script has been provided which takes care of assigning the character, during the testing phase, a BlendTree controller which allows us to have a correct walk speed whatever the setting of the scene. Once we have identified the best environment, we will have to assign the walking and running speed only once. 

If you wish, you can move to the Test area (optional) tab and draw the area where your character will walk. In this case you will have to change its walking and running speed for each scene. Immediately below the list of environments, you will find the fields to change these values (visible only in Play Mode).

 

The two options are not mutually exclusive: if you have drawn an area, clicking on the Nav Mesh will move the character, but you can still use the Play button to make it walk along the reference line.

Let’s now try the found scenes. We enter Play Mode.

If we click on the link the environment will simply be set, if instead we click on the Play button the environment will be set and the character will be moved to the beginning of the reference line. 

After about a second the character will start walking along the line and you just have to count the steps. It will stop on its own once it reaches the opposite side and will return to the starting point. In the Inspector you will find the number of suggested steps based on the Step length parameter which you can vary as desired.

In this testing phase the character cannot be moved with a mouse click if you have not created the test area.

If the results do not satisfy us, we can repeat the search by modifying its parameters.

Once the most suitable environment or environments have been established we can return to Edit Mode and click on Exit searching. All search settings will be deleted but the environments will be preserved along with the area if you created it.

Save selected environment

Environments can be saved in both Play Mode and Edit Mode.

When you click on an environment. it will be proposed for saving. You can change its name.

It will be saved in the VB2Dto3D Tools/Scene data folder in one of the two predefined folders: 2.5dTK scenes and Clean scene, according to your needs. The save folder will have the name of the scene. You can save multiple environments for each scene.

If you need to create a new scene to manage yourself choose Export clean scene. In the folder you will find the prefabs of the Background Camera and all the Main Cameras that you have chosen to save.

Create a new scene, drag the two prefabs and delete the default Main Camera. Your scene is ready to be managed. Remember that the Background camera requires the VBBackground layer.

If you need to transfer the scene to 2.5d Toolkit, use Create 2.5dTK data file.

You will get a text file with camera and character settings.

Create a new scene in 2.5d Toolkit and initialize it as usual. Use the same background image. Set the Main Camera and the Character. Now you can create your own walkable and non-walkable areas, and use the tool as you need.

Legend

Max environment to find
[Number](integer, from 1 to 100): maximum number of environments allowed.
The script will warn you when the limit is reached and will stop the search, while keeping the environments found.

Reference line
[Length](float, from 1 to no-limit): desired length in meters of the reference line.
[Range +-](float, from 1 to 100): range in percentage. e.g. 5, considers reliable any measurement that falls within 5% more or less than Length.

FOV
[Step](float, from 0.1 to 1): Variation step.

Camera rotation
Minimum rotation on the X axis cannot be defined. The script will take care of managing this value.
[Max](float, from default minimum to 90): Maximum allowed camera rotation on the X axis.
[Step](float, from 0.1 to 1): Variation step.

Camera position
Position on the Y axis cannot be defined. The script will take care of managing this value.
[Step](float, from 0.1 to 1): Variation step.

Character
[Minus/Equal](float, from 0.01 to 1): to consider the environment acceptable, the script checks that the character keeps the proportion set in the two points of the scene.
For every possible configuration, the character is scaled to the closest point to the height defined in the initial settings and compared with the resulting height at the furthest point.
e.g. 0.1, considers reliable any measurement that is equal or less 0.1.

Button <Store 1st point>
Place the character in a point that gives you a reference to set its height.
Click the button to store the position and scale.

Button <Store 2nd point>
Place the character in a second point that gives you a reference to set its height.
Click the button to store the position and scale.

Button <Goto the near point>
Move the character and resize it as per settings.

Button <Goto the far point>
Move the character and resize it as per settings.

Button <Start searching>
Search all possible environments according to the settings.

Button <Stop searching>
Stops the search, but keeps the environments found.

vbgamestudio
Author: vbgamestudio