Because NavMeshes are only for pathfinding. If you want to use Direct control, you have to make use of Colliders to restrict your player's movement.
A tutorial on placing down colliders in your scene can be found here. Though the tutorial is for 3D, the same principles apply for 2D - just use the CollisionCube2D button instead of CollisionCube.
I have trouble with the interaction: if I'm correct, the Use is assigned to left mouse button and Examine is assigned to right mouse button. I've set up an Examine which switches the camera and zooms in on the tree. But when the interaction is over and the camera zooms out, If I press the left mouse button during that transition, I can activate also the Use, which spawns a dialogue. How can I prevent the user to add another action while Examining something?
Gotcha. I have another weird problem with the Sorting Map. I've followed the tutorial, and my character should walk behind the Tree. It behaves correctly if I'm clicking from a point near the tree to another point near the tree. However, if I click from a distant point (say, the left part of the scenario) to another (say the right part), my character ignores the Sorting Map and walks in front of the tree. How can I fix that?
Sorry for the multiple questions, but I'm doing a graphic adventure for my university and I'm really on a short deadline. ;_; This tool is awesome, seriously, and I'm liking every bit of it.
No problem, but you'll have to provide more detail than that for me to help. Screenshots of everything would help a lot. Have a look at the character's sprite when it fails - is it on the correct layer, and at (0,0,0) position?
Nvm, it seems now that I've changed the Sorting Map that the problem is not there anymore. However, I still have trouble. The Parent is on Ignore Raycast Layer, the Child is on the Default Layer.
My character is weirdly in front of the tree, even if there is a Hole in the Navmesh. Maybe I need to grasp better how the Sorting Map does work. I'll post also my Navmesh and my Sorting Map, so you can help me.
The NavMesh hole and SortingMap have no bearing on one another.
Your middle SortingMap axis needs to be placed in the centre of the tree's base, not at the bottom. Your character's sorting order will change as they cross that boundary in the y-axis, so if they're above it then they'll be rendered underneath the tree.
If you're having trouble grasping the concept of things like SortingMaps, @zeek has made an excellent tutorial here.
I'm grasping more the SortingMap, but I have still a question. Why can't I create more SortingMaps? Because I have many trees in the scene that I want to be able to walk behind.
I've seen the video but I don't get which area exactly the SortingMap affects.
SortingMaps are made up of sorting areas - in your screenshot, you have two. But you can make as many areas as you like - one for each tree. You should only need one SortingMap for your scene.
But I can't move them on the X axis. They're all linked together and I can move them only on the Y axis. I don't know how to position the various areas in different places of the background.
You don't need to worry about the X axis - the Sorting Map will affect your Player sprite's sorting order as they move vertically through the scene. Unless I'm missing something, you shouldn't need it to change as you move horizontally.
I have really trouble in grasping the concept behind the SortingMap. They're obligatory to be used? Can I just have a different layer for the trees and not change dynamically?
Sorting maps are not that difficult dude, althogh took me a few goes before it all became clear,
Essentially, they change the order of a sprite between the points.
You'll want the first (top) of the sorting map at the top of your floor (or highest place walked too), and the final one at the bottom.
Example below:
tree ( -20 order of sprite) | | | -10 (area 1 in sorting map) | | bench ( 0 order of sprite) | | | +10 (area 2 in sorting map)
| | desk +20 ( order of sprite)
When the player is between tree and bench the order of the player will be changed to -10. Since the tree is -20 and bench is 0, player will be ordered between them.
If player then moves forward to area 2 of the sorting map, it will be then between the bench and desk and have an order of +10.
Dont be afraid of using big numbers, to give your self more room of ordering sprites, eg:
sky is -1000 and bushes -950 floor is usually -900
This way, if you put things (made later in development) between these items, you can add them in without changing all the other sprite orders.
Thank you very much for the explanation! I still have problems, though. This is my sorting map: the character only walks behind the left tree and the upper part of the right tree. But I can't manage to make him walk behind the right tree. Where do I make mistakes^
You'll want one point at the front of the and another at the back. You kinda got that now. dont know why there are two really close together in front of the tree tho.
make sure your player is at 0, have the point behind it negative (-10 or something) and one in front of the tree positive (+10)
Note: Each point should be decreasing in value, so the top one should be minus. the bottom should be positive. All values between going from one value to another, so dont know why you got an 8 in the middle of your sorting map.
I will post screenshots of my game later and show you my setup xD
I've probably found the problem! My character changes the order dinamically, but it's not the same that I've inserted in the Sorting Map. I've setup a Sorting Map with 1 and 6, but when my character walks in the two zones he gets in the 4 and 9 order. Why this happens?
Comments
A tutorial on placing down colliders in your scene can be found here. Though the tutorial is for 3D, the same principles apply for 2D - just use the CollisionCube2D button instead of CollisionCube.
Your middle SortingMap axis needs to be placed in the centre of the tree's base, not at the bottom. Your character's sorting order will change as they cross that boundary in the y-axis, so if they're above it then they'll be rendered underneath the tree.
If you're having trouble grasping the concept of things like SortingMaps, @zeek has made an excellent tutorial here.
Essentially, they change the order of a sprite between the points.
You'll want the first (top) of the sorting map at the top of your floor (or highest place walked too), and the final one at the bottom.
Example below:
tree ( -20 order of sprite)
|
|
| -10 (area 1 in sorting map)
|
|
bench ( 0 order of sprite)
|
|
| +10 (area 2 in sorting map)
|
desk +20 ( order of sprite)
When the player is between tree and bench the order of the player will be changed to -10. Since the tree is -20 and bench is 0, player will be ordered between them.
If player then moves forward to area 2 of the sorting map, it will be then between the bench and desk and have an order of +10.
Dont be afraid of using big numbers, to give your self more room of ordering sprites, eg:
sky is -1000
and bushes -950
floor is usually -900
This way, if you put things (made later in development) between these items, you can add them in without changing all the other sprite orders.
make sure your player is at 0, have the point behind it negative (-10 or something) and one in front of the tree positive (+10)
Note: Each point should be decreasing in value, so the top one should be minus. the bottom should be positive. All values between going from one value to another, so dont know why you got an 8 in the middle of your sorting map.
I will post screenshots of my game later and show you my setup xD
I will try and remember
Give it an hour or so and i should be able to put some up XD