Understanding decorator nodes

The biggest difference between a composite node and a decorator node is that a decorator can have exactly one child, and one child only. At first, this may seem unnecessary as you would, in theory, be able to get the same functionality by containing the condition in the node itself rather than relying on its child, but the decorator node is special in that it essentially takes the state returned by the child and evaluates the response based on its own parameters. A decorator can even specify how its children are evaluated and how often they are evaluated. These are some common decorator types:

  • Inverter: Think of the inverter as a NOT modifier. It takes the opposite of the state returned by its child. For example, ...

Get Unity 2017 Game AI Programming - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.