Simple question re official FSM example

NodeCanvas Forums Support Simple question re official FSM example

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #14941
    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!

    Attachments:
    You must be logged in to view attached files.
    #14949
    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!

    Join us on Discord: https://discord.gg/97q2Rjh

    #14957
    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. 🙂

    Attachments:
    You must be logged in to view attached files.
    #14964
    Gavalakis
    Keymaster

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

    Join us on Discord: https://discord.gg/97q2Rjh

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