One of the important features modern games have is the ability to attach objects of various kinds to other objects. For example attaching an arrow to an actor once hit or attaching a weapon to the hands of a player actor. Game engines use various way to solve this problem from script only to engine only solutions. The Drag[en]gine takes a mixed approach in which the speed of an engine only approach is mixed with the extendibility of a script only approach. In short this is summed up under the term of "Attachment System".
Every object in the script can add to a Scene one or more Colliders. A collider is an engine object which is driven by the Physics Module and provides collision detection as well as physical simulation if required. Every collider can be equipped with a ColliderListener that reports events happening to the script. Using those events the script objects can be altered. Every collider is able to be driven by pure physics ( Dynamic Response ) or by rules specified by the script ( Kinematic Response ).
Colliders exist in various forms. The following list shows a short summary of them.
Collider Volume: A collider volume is defined by one or more collision volumes which define the shape of the collider. Such analytical shapes like a sphere, a box or a capsule are very accurate and fast. Most simple objects can be wrapped in such a collider volume.
Collider Component: A collider component is defined by a Component object assigned to it. The collider builds the collision shape from the informations stored in the Rig assigned to the component ( if existing ). In this setup a collider comonent behaves like a rag doll. Bones are driven individually in this setup and the result directly spills over to the graphic system ( using the same component object ). If no rig exists a component collider boils down to a collider volume with a triangle mesh as the used shape. Hence collider component is also the choice for objects which can hardly be represented with a set of collision volumes.
Collider Rigged: Rigged colliders are a special class of colliders provided for those special cases where you require a rigged setup ( as specified in a rig resource file ) but there is no component directly assigned to it. Such rig only constructs can be helpful for AI interaction with environment where the collider is required only to determine the next actions of an actor but the objects itself are then positioned using completely different algorithmes.
Once a collider has been chosen and put in charge the attachment can begin. Every collider is able to host a set of other colliders attached to it. You have a couple of ways to attach colliders. You as game designer have no need to worry about how they are calculated as the Physics Module is fully responsible to update attached colliders correctly in time. You only have to set them up and respond to the events that occure over time. Here the list with the attachment types and a short summary for each.
Static Attachment: Is best used if an object has to keep the same position and orientation with respect to some other object at all times. You simply specify the position and orientation in this case. Works with all collider types.
Rig Attachment: The choice for cloth and all sorts of objects you put on an actor that are required to deform using his rig setup. You do not have to specify any more informations for this case. Works only if used on component or rig colliders ( as only they have a rig somewhere ). The object is matched onto the rig of the parent collider and the bone position and orientation copied over.
Bone Attachment: Keeps position and orientation static in respect to a bone in a parent collider. Obviously also works only on comonent and rig colliders as only they have a rig. Like in the static case you specify the position and orientation relative to the tracked bone. This is typically used for placing a gun in the hand of an actor for example.
Weight Attachment: This is a cross between the rig and bone attachment type. You specify a list of bones used to position the collider. Each weight entry defines a bone ( by name ), a weight factor ( between 0 and 1 ), a position and an orientation. You can imagine this as a vertex deformed by a set of bones in a rig just that here a collider is positioned instead of a vertex. For the same reasons this works only on component and rig colliders. This is the attachment of choice for projectiles getting stuck in deformable objects.
With this system all sorts of setups can be created without a lot of work. The current scripting module provides a set of simplistic functions so you do not have to worry about the details. So for example attaching a collider weighted you only have to provide the CollisionInfo that you obtained from a collision event and the needed calculations are done for you.
One question that may quickly arise is what happens to something like a joint/hinge? The collider component can take such informations from the rig resource file and build a proper physics setup from it. What goes for joint/hinge/spring connections between colliders this is handled using a different set of objects. Attachments are static hence the position of the collider is fully defined by the attachment. Joint/hinge/spring connections though allow colliders to end up in various valid positions and are not static. Hence keep in mind what sort of connection you want to have. If it is static use Attachments and if it's dynamic use Joints.
If you have questions just post them here.
All sorts of discussions about the Drag[en]gine Game-Engine
Post Reply[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
1 post[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
•Page 1 of 1
•Page 1 of 1