• CollisionTriggerComponent (Components\TriggerComponents\CollisionTriggerComponent.cs) 
    • The collision trigger component is a basically a component that listens for collisions (Entities entering and exiting the physics volume of the Entity the trigger resides on).
    • As of version 0.2 this component can affect other entities with CollisionEffects. However, in a future release we will be letting your register your own custom events that will fire either when an object enters the trigger, or exits.
    • For an example on using this component, let’s look once more at SampleScene.cs, in the BoxAntiGrav() function.
      • You can see here that we are choosing between two different template IDs based on whether or not the box is invisible. If you were to look at what those entities define in the EntityTemplates.xml file you'd see that the invisible box just has no render component, it's that simple.
      • Let's take a look at the component definition XML file for this component, it's a bit different than others. In the sample demo it is located at 'Content/Entities/ComponentDefinitions/CollisionTrigger/PushUpwardTrigger.xml'.
        • You'll notice there is only a single parameter, and that is the path to another XML file, this will be the XML file that has a list of all collision effects this trigger handles. The path to that file is relative to the Content directory, so it is located at 'Content/CollisionEffects/ConstantPushWorldUp.xml'.
        • The asset type for this collision effect file is an array of CollisionEffectDefinitions. Each CollisionEffectDefinition describes an effect that will occur on something that is colliding with the Collision Trigger. In this example we see there is only one effect in the list, but there is nothing stopping you from using multiple effects, which will be more useful once more effect types are created (or if you create your own).
        • For the parameters you need a unique effect ID, this allows you (if you wish) to dynamically make changes to the effect during the game through any messages handled by the CollisionTriggerComponent, those messages have a parameter which is that effect ID.
        • The other parameters are the type of collision effect, which is defined by the enum CollisionEffectType within CollisionEffect.cs. The next parameter is 'IsDirectional', which should be true if the effect has a direction to it (which the ones in the demo do), then the 'Direction' parameter needs to be something other than (0, 0, 0) if you set 'IsDirectional' to true, and finally the 'Strength' is how strong the effect is, in the case of a directional effect it is 'units per second'. So an effect with a direction of (0, 1, 0), and a strength of 10, will have an upward effect at 10 units per second.
      • What you will see in the demo is a blue box that will launch other dynamic physics objects upward when they enter it. Fun stuff.

Last edited Jan 5, 2012 at 4:44 AM by LordIkon, version 1

Comments

No comments yet.