Hello everyone! We are back with a new DevLog, in the previous entry we saw how the lights can help us create an atmosphere and give more realism our game. This time we will see how we create the scenarios in Green Mirror and we provide them with logic, we will also talk about Adventure Creator (AC) which is the plugin that we use for the logic of actions and movement. Let's go to the mess!
First of all we wanted to talk about AC and how we separate the scenes. AC is a plugin that facilitates the creation of graphic adventures, and we strongly recommend you if you are thinking of making one, either 2D or 3D. AC provides us with the whole system of movement, inventory and interactions with the environment.
AC also provides a scene management but in Green Mirror we have decided to incorporate our own system that allows us to load scenes of additive form and pre-load them to avoid screens of load or pulls. This way, when we are in a scene, the adjacent scenes will be loaded in the background and kept hidden until we change the scene, at that moment the scenes that are not already connected are downloaded in the background and the new adjacent ones will be loaded.
Once commented this we go to the crux of the matter:
As AC needs its own scripts (obviously) to maintain its entire system and there can not be duplicates, we have a main scene that we usually call "Core" and it will always be the active scene, and for each scene (or room) in the game We will create a Unity scene which we will add to the scene in order to work with it. If you want to see more information about how to work with additive scenes you can consult this link in the Unity manual.
We have already made the first step, on the one hand we have the main scene with the scripts of AC and everything reusable between scenes and on the other hand a scene added additionally on which we are going to work. The next step will be to add all the art necessary for our scene. As the character, Riley, can be in front of or behind some objects, has depth, the stage we have divided into pieces, or layers, so that we can assemble a puzzle that allows us to give depth and that the character is at the height that should.
For this particular scene we will use the following elements:
With these elements we begin to mount the scene assigning the sorting layer of the sprite, being “ 0 “ the deepest element, let us also not forget to assign the material so that the light affects our scenario.
Let's now configure the sorting map of AC, the sorting map will allow the characters to change their sorting layer dynamically according to the position they occupy, in addition we can also configure a scale so that the character becomes smaller when entering the bottom of the stage and bigger when approaching the front of the stage.
With the sorting map configured we can prepare the nav mesh by which the characters will move, in our case being a 2D game, and thanks to AC, we will use a polygon collider and set it as a trigger.
Now we have the scene ready for the characters to be able to move for him, but they lack logic. For this we use the Hotspot component of AC that already has the logic to detect the user inputs and display the actions menu, also allows us to assign a list of actions for each type of action or inventory object that we use on this hotspot.
In this image we can see all the hotspots assigned on the scene:
We will now see how we create a simple action that allows the character to interact with an object and add it to the inventory. First we create the action and edit it. For this action we want our character to use an animation to use / pick up, play a sound, add the object to the inventory and hide the object from the stage, we also have to deactivate the hotspot so that it can not be re-interact with it.
And this is the result:
We hope you have found the post interesting, as always, any question you have do not hesitate to ask us. See you at the next post, greetings!