Instance and Motion Functions

From ENIGMA

Jump to: navigation, search

This article is an overview of all instance and motion related functions.

When moving objects around it is also necessary to plan for collision detection to determine whether or not the objects can move to specific places or when they enter certain regions that should trigger certain things to take place.

The rest of these collision functions do actually return boolean values.

The following functions help with activating and deactivating objects that are not currently in view or out of the scene, they can help speed up games. Instances that become deactivated will stop processing their events which is what allows the game to speed up, there is no point in having objects which are not visible on screen being animated for example.

The following are used to achieve motion planning for instances. To use these functions you must enable them in the extensions tab under Build->Settings. It is important to note that motion planning is a relatively difficult task in computer science, and it is impossible to provide a set of functions that work in every possible usage scenario.

The first set of functions are not full motion planning but achieve similar or close affects with less accuracy. They calculate movement based on object locals and will generally fail more complicated tasks such as finding a way out of a maze.

The next functions are used to generate a collision-free path to a particular position. The path can be assigned to an object for it to follow. The computation of the path may be slow but once it is computed the execution of the path is just as quick as having an instance follow a regular path. This is of course unless the scene changes in which case the path will need to be recomputed. Also note that these functions may also fail certain tasks like the former functions.

The final set of functions use a much more complex mechanism based on grids (often refereed to as A* path finding). The functions may not be quite as easy as the earlier functions but will calculate more accurate paths, however they may still fail certain tasks and take longer to compute.

The functions work by defining either a fine grid (slower to compute) or a coarse grid. Once the grid is defined we must mark cells of the grid that the objects should not be allowed to enter (forbidden) by detecting collisions with existing instances (either using bounding boxes or precise collision checking) that even partially overlap the cells of the grid. Finally we set the initial starting and ending position in an area of the grid that is not marked forbidden and then the function will compute the shortest approximate path between the two positions. The path will pass through the center of collision free cells so long as the cells are big enough to fit the passing instance. Once the path is computed an instance can then begin following the path.

A* path finding is very powerful and is featured widely in many professional games, such as strategy games, which feature artificially intelligent opponents. It is crucial that you account for certain scenarios when designing your path finding to achieve the most efficient results. For instance the size of cells must be large enough so that if the instance were placed with its origin aligned to the center of the cell it will not extrude the boundaries of the cell. It is also possible to shift the path if the origin of the instance is not centered. Smaller cells result in more possible paths, and if cells are too large openings between obstacles may be impassable because all cells intersect an obstacle.


Personal tools
Namespaces
Variants
Actions
Navigation
ENIGMA
Other
Toolbox