VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
12.6 - Handling Unachievable Tasks

The API has functions that let you write code to handle situations in which a task is unachievable.

For example, suppose you have a ground vehicle and you give it a task to move to a waypoint, but there is already a simulation object at that waypoint. In this situation, the vehicle would never be able to successfully reach the waypoint. It would continuously try to reach that point, until it ran out of fuel. Therefore, you would like to add some reasoning to the simulation object, so that as it approaches the waypoint, it can evaluate the situation and take some more sensible alternative action, such as parking nearby.

Handling unachievable tasks is done on a per DtTaskControllerComponent basis. It has member functions, decideToGiveUpTask() and giveUpTask(), that let you add code for handling unachievable tasks. The decideToGiveUpTask() is a function that returns a boolean flag indicating whether or not the simulation object should give up its current task. It is called immediately after every tick when the simulation is running (in play mode) and simulation object is tasked. If it returns true, then it calls giveUpTask(). The giveUpTask() function provides a place where any special handling, such as calling taskComplete(), can be added. By default, the function decideToGiveUpTask() returns false, and the giveUpTask() function has an empty implementation.

The decideToGiveUp example demonstrates how to use this feature.

[<< Starting and Processing C++ and Scripted Tasks] [Home] [Adding a User Task >>]


Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)