Forum rules - please read before posting.

Hotspot Walk-to-marker actual behavior

edited December 2017 in Technical Q&A
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...:

image

Thank you for reading.

Comments

  • When walking to a Marker, the game will wait until the player has reached their desination and then run the interaction.  It's nothing to do with timing, just the assumption that they're ready to run the interaction once they've stopped moving.

    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.
  • Mmm, problem with 'Straight to cursor' is that you actually need to click inside the NavMesh (unless I did something wrong), and my game is actually a side-scroller with very thin NavMeshes so the characters can move "on rails", but still be able to click in the general direction and the player moving there. That's why I picked 'Point & click' method instead.

    I also wanted to include the option to activate exit hotspots without releasing the mouse button, which I don't know if 'Straight to cursor' is capable of out of the box.

    Anyway, that method you say will help me, no doubt! Thank you for pointing me in the right direction.

    By the way, I didn't find it because of how the search facility in the scripting guide page works. When I write a word in there, I get a list of topics that start with that word, not of topics containing the word. So I'm forced to know where to look exactly in the first place.

    And if I go and press enter, I get a LOT of results but they're not filtered on the left panel, which makes the entire business of looking for something specific quite hard.

    Could it be possible to enhance it in some way, do you think?
  • The intricacies of Doxygen (on which the scripting guide is built) are a bit beyond me, but I'll look into it.

    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.
  • Yup, I've already done that and it's working well.

    Thanks for everything, as always. :)
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.