Forum rules - please read before posting.

How to Prioritize Mouse over callback over navmesh2d

HI,

I am trying to write something like a hotspot(with a long click to active it)

However the mouseover callback doesnt get call when the object is inside navmesh2d.

i would like it to function exactly like AC hotspot which is when i click the hotspot ,it triggers without player run to it.

Comments

  • Just to make things clear and check if there are smarter way, the thing i actually want to do with hotspot is

    out side the hotspot detection boundary

    on single click

    player move inside the boundary of the hotspot

    inside boundary

    on mouseover and mouse down

    check hotspot trigger condition

    if match

    stop player movement if he still moves

    wait for long click time

    trigger the hotspot

    I already wrote my own hotspot method. but i am not sure how to put it into ac , if it is better.

  • Checking Place distant Hotspots on separate layer? will cause Hotspots outside of the Player's "Hotspot detector" to be moved to the DistantHotspot layer. This should cause clicks on them to be ignored in favour of the NavMesh.

    If you're writing your own Hotspot interaction system, you can rely on Unity's Input system to read the mouse position / click-state, which won't interfere with AC's own mouse clicks.

    See the included CustomInteractionSystemExample.cs script for more on how to trigger Hotspot interactions directly. The ClickByHoveringCursorExample.cs script also demonstrates how Hotspot interactions can be triggered after a given time has elapsed.

  • Thx for pointing out a direction for me, i will go study those script.

  • I've do my study and wrote my custom interaction method.

    There is still one question remains as the thread suggested
    There exists sometime i would like to intercept the left click on navmesh
    So that when i clicked on a hotspot(custom one) the player will ignore the click on navmesh2d, and do only what the hotspot says.

    i read the ac hotspot script and tried to find out how you manage to stop that.

    1. i tried ResetMouseClick()
    2. using player.Halt();

    So far i can only stop the player after a 0.2f delay, which player already facing different direction.

  • Make sure that your script runs before AC's StateHandler script, so that calls to "ResetMouseClick" are made before AC can read the mouse state. You can do this by giving it a negative Script Execution Order.

    You could also try disabling AC's input system completely for a frame, which can be done with:

    AC.KickStarter.stateHandler.SetInputSystem (false);
    
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.