Forum rules - please read before posting.

NavMesh search direction not behaving like I thought it would...

Hi all, my first post here... :) 

I'm struggling with Point & Click movement and clicking outside the navmesh.

I've did a search about my problem and got some threads of which the most promising was this one.

...but it seems that the proposed solution doesn't work for me.

I have a 2D side scroller game with an enlongated and narrow navmesh which is used by the player character to move "on rails" across the game area.

One thing I loved about this kind of system is that if I set NavMesh search % to 1, then it's possible for the player to click anywhere on the screen and the character will move in that direction without the need of clicking exactly over the destination point inside the navmesh. And I'm perfectly happy with that.

But... I also have a canvas UI image that it's sitting at the bottom part of the screen. And I'm starting to code OnClick events in some prefab objects that end up over that image in the canvas. And I've just realized that if I click anywhere over to UI image and those prefabs... well, the character also tries to move over there! :))

I understand this is normal behavior because I had NavMesh search direction set as Radially Outwards From Cursor. And what I need is for all clicks beneath the navmesh to be completely ignored by AC's movement system.

So I did as suggested in that other thread and change the setting to Straight Down From Cursor. But the player character is still trying to get there.

I don't know if I've misunderstood the nature of that setting, but I really need AC to ignore those clicks. Is there a way for me to do this?

By the way, I'm also using PlayMaker and I've tried to send an event to AC to 'freeze' the player before any other action in the FSM. I do this by calling two cutscene actions:
  1. Player: Constrain -> Movement: Disabled
  2. Engine: Manage system -> Movement method: none; Input: Disabled; Movement: Disabled
Maybe it's a little overkill to stop the character on its tracks, but truth is that it still has the chance to move a little (not very much) before these actions get triggered and executed, like if the Point&Click routines have a much higher priority to be run in the game. Also... it doesn't looks pretty... :(

So... could I envelop the canvas UI image with a box collider and tell AC to basically ignore every click that goes in that collider, without the need of trying to 'intercept' the player movement...?

Thank you for your time. I hope I've explained myself well enough. ;)


  • Ok, I resourced to a VERY cheap trick...

    I've simply put a null Hotspot (that it does nothing) over the bottom area in the scene. And then I attached it to my main tracking camera as a child so it moves along with it.

    Mouse clicks are still caught through the canvas UI, but they don't trigger any player movement because this hotspot doesn't have any interaction set.

    So my problem is solved now but, out of curiosity I still would like to know why this...:

    From Chris: "... However, you may want clicks that are above the NavMesh to have an effect - in which case you should instead set the NavMesh search direction to Straight Down From Cursor." not working as I understood it should.

  • Welcome to the forum, @Anaxtasia.

    Indeed, blocking clicks to AC's movement system is going to be better than intercepting player movement.  AC only allows for a single mouse click to affect one single system - so if you hooked up your UI to AC's Menu system then clicks that are made on the UI would be blocked to the movement system automatically.

    However, you can reset the click manually with the code line:

    AC.KickStarter.playerInput.ResetMouseClick ();

    Regarding the Straight Down From Cursor option, that causes the search to occur downwards first before attempting a radial search.
  • Thank you Chris.

    I'm using Unity UI system instead of AC's, so I suppose that's the reason I couldn't get those clicks handled by AC as a menu click, yes. I've managed with that little trick, but if it gives me problems in the future I'll do as you say.

    And about the search option it seems I also misunderstood the functionality of that setting. :-?

    To be honest I'm using AC in a very un-adventure like way in my game, he he... so it's bound to give me headaches from time to time. Nothing major for now.

    Thanks for your help!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.