Running action composed of few smaller actions?

NodeCanvas Forums General Discussion Running action composed of few smaller actions?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #9100
    zxc

    I’m learing to use Running behaviours.

    I would love to have a block of methods that’s running (rather than a single node). I would expect the whole block to be executed each frame until the “defining” behaviour is finished. For instance take a block like this: A(), B() and Wait(“5”). That would execute A(), B() for every tree evaluation as long as Wait(“5”) is running. Effectively it would allow to make custom running behaviours without much coding.

    How should I approach that?

    Real world example is an Enemy that tries to circle a Player for a momement: sequence of SetDestination() and Wait(“1s”); and I want this enemy to point his gun directyly at the Player during the circling, by executing Aim() method every frame. Only option to do this is to create an Implemented Action that’s basicly just like “Wait”, but also contains the Aim() invoke. That seems like an overkill.

    I don’t see an easy way to build complex Running actions from atomic methods. It’s a major drawback, in my current understanding. I see that this problem should be solvable without additional coding. I’m guessing that it could be an extension of Action List – maybe a special check box for this kind of behaviour – so the actions would be repeated as long as any node is Running. Or maybe it should be like a “Decorated Wait” node, that executes given functions for X time? I’m not sure, but it’s all about the question of easily combining methods that are executed for more than one frame of a tree.

    I just don’t know how to do it well!

    #9104
    zxc

    I tried various combinations and this pictured pattern gives the desired result: http://imgur.com/j9bK2G5.

    As long as the “Wait” action is running, Aim() node will be executed. “Optional” decorator is necessary here – otherwise the Aim() node is never reevaluated (possibly because it doesn’t have an impact on sequencer’s state).

    I’d be glad to make this kind of consturctions with just a single node, like a special kind of Action List. Is this a viable approach, does anyone use it?

    #9103
    Gavalakis
    Keymaster

    Hey again,

    The “correct” pattern to do what you want, is to use a Parallel and a Repeater, since that is exactly what you want to do> Run a parallel action repeatedly for 1 sec. (I’ve attached the pattern)

    Because the parallel is set to break/stop is First Success, as soon as the Wait Action ends (which always returns Success when it ends), the parallel returns Success as well. As long as it is Running the Repeater is doing it’s stuff and repeats the child node forever.

    With that said, I could alter the Repeat Decorator and add it it another ‘Mode’, Repeat fox x seconds, which in practise will encapsulate the attached pattern functionality.

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

    #9102
    zxc

    Awesome solution, thanks!

    #9101
    zxc

    I tested it and works like a charm. An additional field in Repeater would be great, I even was surprised that it wasn’t there when I checked.

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