Hi Chris,
I'd need some clarification about the actual behavior 'Walk-to-marker' has when a Hotspot is clicked.
I've coded a feature so when the player leaves Left-Mouse-Button pressed for about 0.5 seconds, starts a loop that picks the world position and executes AC.Player.MoveToPoint to that position, every 0.5 seconds as long the button continues to be held.
For just moving around is working well, but I wanted to go the extra mile and interact with Hotspots as well. So I added logic to pick the mouse position, recognize Hotspots and run AC.Hotspot.RunUseInteraction. That way, the player can exit the scene by just hovering door hotspots with the button pressed.
That also worked nicely. The problem comes when the player hovers the hotspot, then changes his mind and without releasing the button goes the opposite side or he simply doesn't hover the hotspot anymore. In those instances, a little time passes and the Use interaction runs all the same as if the character truly reached the marker.
You can find a demonstration video here: https: // youtu. be/ zRQh0xp9iRM
My expectations were that if you hovered on another place, the character would "refresh" its destination, never reach the marker and therefore the Use interaction wouldn't run, but that's not the case. It's running alright.
That suggests me that what Walk-To-Marker actually does is starting a timed walk-to action, taking for granted that if nothing more happens in that time, then it can execute the Use action as the character should be at that marker.
I'd also bet that the only way for that behavior being aborted is an active mouse click, so another action takes place that aborts any other interaction from ending.
Am I right?
At any rate, I'd like to have some kind of workaround so this doesn't happen. Is there some method to cancel hotspot interactions that I could add to my current logic? Which by the way is like this...:
Thank you for reading.
Comments
If you want to cancel the interaction from running, just call the PlayerInteraction script's StopMovingToHotspot method.
However, the behaviour of holding-to-move is already provided in the "Straight To Cusor" movement method. This method allows you to pathfind when single-clicking, and set a minimum-time-threshold for a held click to cause re-calculation. Have a play with those options, as well as the "Pathfind update time" slider - you may find you get your intended behaviour without need for anything else.
Straight To Cursor should allow for off-NavMesh clicking - I'll re-check that. AC on its own requires that Hotspots be single-clicked - and that's separate from the movement method.
But you could consider overriding the InputGetMouseButtonDown delegate to have AC consider a held-down-mouse as a single-click. See the "Remapping inputs" chapter of the Manual for more on this, though if you were having success using PM before it might be easier to just cancel the player's interaction as per your original question.