Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorHitScan
Behavior adding hit-scan support to elements.
Behavior supports using one or more collider collision tests to do one or more hit scans for example to check for weapon projectile impacts. Hit scans are done once then the result can be examine. To use this behavior add ECBehaviorCollider then this behavior. The collider is used to carry the collision tests.
This behavior can be used multiple times on an element to add multiple independent hit scans. Use the behavior identifier to tell them apart.
Element class properties have the prefix hitScan.
or hitScan({id}).
if id is not empty.
Set test range.
hitScan.range
or hitScan({id}).range
<float name='hitScan.range'>0.5</float>
Set test origin offset.
hitScan.offset
or hitScan({id}).offset
<float name='hitScan.offset'>0.5</float>
Set test origin.
hitScan.origin
or hitScan({id}).origin
<vector name='hitScan.origin' x='0' y='0' z='0.2'/>
Set test direction.
hitScan.direction
or hitScan({id}).direction
<vector name='hitScan.direction' x='0' y='0' z='0.2'/>
Set test orientation.
hitScan.orientation
or hitScan({id}).orientation
<vector name='hitScan.orientation' x='20' y='0' z='0'/>
Set test bone.
hitScan.bone
or hitScan({id}).bone
<string name='hitScan.bone'>value</string>
This behavior has no events
This behavior does support element class to be persistable (setPersistable). Saves selected color.
Since DragonScript Module Version 1.0
This example defines an element which contains a hit scan.
class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorHitScan hitScan func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) hitScan = ECBehaviorHitScan.new(this, collider, component) hitScan.getRange().setValue(50) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorComponent'/> <behavior type='ECBehaviorCollider'/> <behavior type='ECBehaviorHitScan'> <!-- optional: use component with id instead of empty string --> <string name='component'>second</string> <!-- optional: set collision filter. default value '1:0 1 2' which means category BaseGameApp.CollisionFilterBit.dynamic filter BaseGameApp.CollisionFilterBit.geometry, BaseGameApp.CollisionFilterBit.dynamic, BaseGameApp.CollisionFilterBit.actor. format is '', 'category' or 'category:filter' where category and filter are a list of bits to set. --> <string name='collisionFilter'>1:0 1 2</string> <!-- set element properties. omit property prefix if used inside behavior tag --> <float name='.range'>50</float> </behavior> <!-- for adding multiple behaviors use unique identifiers --> <behavior type='ECBehaviorHitScan' id='second'/> </elementClass>