Simple question re official FSM example

Forums 💬 NodeCanvas ⚙️ Support Simple question re official FSM example

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #16331
    ledshok
    Participant

      Purchased NodeCanvas in the recent sale and have just started to mess around with the official example scenes provided (in particular the FSM Character Point and Click Control scene).

      I noticed that when you click the mouse the character starts moving towards that point. However, if you click the mouse again somewhere else while the character is still moving to the first point the click is ignored and the character continues to the original destination.

      To allow the character’s movement to be interrupted by a mouse click (so they immediately change direction and head to the new destination) I updated the graph per the attached image.

      Essentially I just copied the existing ‘click’ connection (transition?) and looped it from the Move state back to itself.

      It works, but as a newcomer to NodeCanvas, I’m interested to know whether this would be considered the ‘correct’ way to implement such a behaviour.

      Thanks!

      #16334
      Gavalakis
      Keymaster

        Hello and thank you for purchasing NodeCanvas.

        Yes, this is a very correct solution if you want to do that 🙂
        Another solution would be to link the “Move” state from an AnyState node along with the same transition condition that you already made. This would make the “Move” state trigger regardless of the current state (since AnyState transitions are evaluated per-frame).

        Both solutions are correct however 🙂

        Thanks!

        #16333
        ledshok
        Participant

          Thanks Gavalakis. I appreciate you providing your solution as it’s helped me understand how the ‘Any State’ works and why it would be useful.

          For any other newcomers who stumble across this post, I’ve attached a screenshot of your solution for completeness. 🙂

          #16332
          Gavalakis
          Keymaster

            Hey. No problem and thanks for the follow up.
            Yep, that is exactly the way I meant AnyState to be used 🙂

          Viewing 4 posts - 1 through 4 (of 4 total)
          • You must be logged in to reply to this topic.