by Mike Ton 9 years ago
1013
More like this
(shared)
(global)
(misc)
Entry Task
// The entry task is a task that is used for display purposes within Behavior Designer to indicate the root of the tree. It is not a real task and cannot be used within the behavior tree.
Third Party
Basic Tasks
(built in Unity MonoBehavior???)
Decorators
// The decorator task is a wrapper task that can only have one child.
// The decorator task will modify the behavior of the child task in some way. For example, the decorator task may keep running the child task until it returns with a status of success or it may invert the return status of the child.
Conditional
Random Probability
Compare Field Value
Compare Property Value
compareValue
// The value to compare to
Physics
Has
Exited
Entered
Trigger
Trigger2D
Collision
Collision2D
// This task will not be changing game state and is just checking the status of the game
(sightline, audio radius, collision, physics...etc)
Composites
(or)
Selector Evaluator
// The selector evaluator is a selector task which reevaluates its children every tick.
// This task mimics the conditional abort functionality except the child tasks don't always have to be conditional tasks
// The selector evaluator will return success as soon as the first child returns success otherwise it will keep trying higher priority children.
// It will run the lowest priority child which returns a task status of running. This is done each tick. If a higher priority child is running and the next frame a lower priority child wants to run it will interrupt the higher priority child.
Random Selector
// The difference is that the random selector class will run its children in a random order.
Priority Selector
// The higher priority tasks have a higher chance at being run first.
// Similar to the selector task, the priority selector task will return success as soon as a child task returns success.
// Instead of running the tasks sequentially from left to right within the tree, the priority selector will ask the task what its priority is to determine the order.
Parallel Selector
// The difference is that the parallel task will run all of its children tasks simultaneously versus running each task one at a time.
// Similar to the selector task, the parallel selector task will return success as soon as a child task returns success.
// If every child task returns failure then the parallel selector task will return failure.
// If one tasks returns success the parallel selector task will end all of the child tasks and return success.
Selector
// The selector task is similar to an "or" operation.
// If no child task returns success then it will return failure.
// If a child task returns failure then it will sequentially run the next task.
// It will return success as soon as one of its child tasks return success.
(and)
Random Sequence
useSeed
// Do we want to use the seed?
seed
// Seed the random number generator to make things easier to debug.
// The difference is that the random sequence class will run its children in a random order.
// The selector task is deterministic in that it will always run the tasks from left to right within the tree.
// The random selector task shuffles the child tasks up and then begins execution in a random order.
Parallel
// "And" comparison, but the parallel task will run all of its children tasks simultaneously versus running each task one at a time.
// If one tasks returns failure the parallel task will end all of the child tasks and return failure.
// Like the sequence class, the parallel task will return success once all of its children tasks have return success.
// Similar to the sequence task, the parallel task will run each child task until a child task returns failure.
Sequence
// The sequence task is similar to an "and" operation.
// If all child tasks return success then it will return success.
// If a child task returns success then it will sequentially run the next task.
// It will return failure as soon as one of its child tasks return failure.
// Composite tasks are parent tasks that hold a list of child tasks.
// Every composite task holds the property which specifies if conditional aborts should be used.
// The return status of the composite tasks depends on its children.
// For example, one composite task may loop through the child tasks sequentially while another task may run all of its child tasks at once.
Action
(List)
(var)
(fields)
Set Field Value
Get Field Value
// Gets the value from the field specified. Returns success if the field was retrieved.
(properties)
???
A:
c#
public string MyField{ get{ return _myField; } set{ _myField = value; } }
// this is a property. When you access it uses the underlying field, but only exposes // the contract that will not be affected by the underlying field
private string _myField;
// this is a field. It is private to your class and stores the actual data.
http://stackoverflow.com/questions/295104/what-is-the-difference-between-a-field-and-a-property-in-c
// Properties expose fields. Fields should (almost always) be kept private to a class and accessed via get and set properties. Properties provide a level of abstraction allowing you to change the fields while not affecting the external way they are accessed by the things that use your class.
Q:
??? WHAT IS DIFFERENCE BETWEEN FIELD AND PROPERTIES ???
Set Property Value
Get Property Value
fieldValue
// The value of the field
fieldName
// The name of the field
// Gets the value from the property specified. Returns success if the property was retrieved.
(func)
Invoke Method
methodName
(return)
storeResult
// Store the result of the invoke call
(param)
parameter4
parameter3
parameter2
parameter1
// The name of the method
componentName
// The component to invoke the method on
?? of targetGameObject
targetGameObject
// The GameObject to invoke the method on
// Invokes the specified method with the specified parameters. Can optionally store the return value. Returns success if the method was invoked.
(Tasks)
Wait
waitTime
// The amount of time to wait.
// Wait a specified amount of time. The task will return running until the task is done waiting. It will return success after the wait time has elapsed.
Perform Interruption
interruptSuccess
// When we interrupt the task should we return a task status of success?
interruptTasks
// The list of tasks to interrupt. Can be any number of tasks.
// This will immediately stop the specified tasks from running and will return success or failure depending on the value of interrupt success.
Log
// Log is a simple task which will output the specified text and return success. It can be used for debugging.
Idle
// Returns a TaskStatus of running. Will only stop when interrupted or a conditional abort is triggered.
(Tree)
Stop Behavior
pauseBehavior
// Should the behavior be paused or completely disabled.
// Pause or disable a behavior tree and return success after it has been stopped.
Start Behavior
// Start a new behavior tree and return success after it has been started.
Restart Behavior Tree
(args)
behavior
// The behavior tree that we want to start. If null use the current behavior
// Restarts a behavior tree, returns success after it has been restarted.
Behavior Tree Reference
The Behavior Tree Reference task allows you to run another behavior tree within the current behavior tree. You can create this behavior tree by saving the tree as an external behavior tree. One use for this is that if you have an unit that plays a series of tasks to attack. You may want the unit to attack at different points within the behavior tree, and you want that attack to always be the same. Instead of copying and pasting the same tasks over and over you can just use an external behavior and then the tasks are always guaranteed to be the same. This example is demonstrated in the RTS sample project located on the samples page.
The GetExternalBehaviors method allows you to override it so you can provide an external behavior tree array that is determined at runtime.
// The Behavior Tree Reference task allows you to run another behavior tree within the current behavior tree.
// This task is going to be changing the game state
(updating runtime gameobject, transform, properties...etc)
(props)
bool???
instant
//This is an easy way to throttle the behavior tree.
//Else when a task returns success or fail it immediately moves onto the next task within the same update tick
//Uncheck the instant task it will now wait a update tick before the next task gets executed.
string???
comment
name
(funcs)
public
Behavior
Owner;
// Keep a reference to the behavior that owns this task
virtual
TaskStatus
OnUpdate();
// OnUpdate runs the actual task
void
OnDrawGizmos();
// Allow OnDrawGizmos to be called from the tasks
OnReset();
// OnReset is called by the inspector to reset the public properties
OnBehaviorComplete();
// OnBehaviorComplete is called after the behavior tree finishes executing
GetPriority();
// The priority select will need to know this tasks priority of running
OnPause(bool paused);
// OnPause is called when the behavior is paused and resumed
OnEnd();
// OnEnd is called after execution on a success or failure.
OnStart();
// OnStart is called immediately before execution. It is used to setup any variables that need to be reset from the previous run
OnAwake();
// OnAwake is called once when the behavior tree is enabled. Think of it as a constructor
//Tasks have a similar API to Unity’s MonoBehaviour
The following flow chart is used when executing the task