I'm developing a side-scroller adventure game.
I want the player to be able to click anywhere on the screen and walk in that direction, stopping at the X coordinate of the clicked point.
To that effect, I've created elongated polygon NavMeshes. They're not very thin to allow for some vertical movement, but for the most part, the only movement I'm interested in is horizontal.
Now... taken from the manual...:
"There are several options related to how the player's destination when clicking is determined. The NavMesh search % (in the Settings Manager) allows you to choose how far from the cursor the game will search for a NavMesh, if one was not clicked on directly. If this is greater than zero, you can use the NavMesh search direction to determine if the search is conducted radially outward from the cursor, or straight down."
This is why I thought I should pick "Straight Down From Cursor" as the NavMesh search direction.
My expectations were that if I click at a point over the player character, she would remain basically in place, as the cursor would be horizontally positioned only some pixels away, either to the left or right.
But that's not happening. See this capture...:
She walks far to the left, instead of just turning a bit and keep in place.
And in other instances, she keeps in place, but goes either down, when she's at the upper limit, or she goes up when she's down. And my expectation there would be for her to always stay at the top of the NavMesh limit.
All in all, it doesn't seem the destination is well calculated, or at least not as I expected from reading the manual, that is.
These are my settings:
Am I mistaken about how this works?
Thank you!
Comments
I'm afraid your screenshot is not too clear to me - please don't crop images. Where is the pointer clicking in the image?
What you're expecting is indeed what should be occuring - the 2D Demo has this behaviour. Please load up the 2D Demo in your project and check that it behaves how you're expecting.
Custom camera components are certainly possible - but you must do it the right way. Please see Section 4.6 of the Manual - such components must not be added to your MainCamera, but instead kept separate and made "visible" to AC by attaching the "_Camera" component.
Once your component structure is set up correctly, we can then see about any compatibility issues there may be.
Yes, you should make sure the MainCamera is attached to a GameCamera before anything else. Also be sure to click Revert at the top of the MainCamera, so that it is set to the original state of the prefab.
That the 2D Demo works for you is encouraging - there must be some key
element in your own game that has been overlooked. This means, however, that we can use the 2D Demo to compare any differences, which should help us isolate the problem. Try the following experiments:
1) Place the 2D Demo's player, Brain2D, into your scene and run it. Does he also move to the wrong place?
2) Load the 2D Demo's scene, Park, without re-assigning your Managers so that your own Managers are running while the 2D Demo runs. This way, we can determine if the issue lies with your Managers.
3) Then, try the opposite - load the 2D Demo's Managers into your AC window, and run your own scene. This way, we can determine if the issue lies with your scene.
Bear in mind that this is all temporary - we can re-introduce your removed elements later. This can all be done in a separate temporary project if you prefer.