Table of Contents

,

Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorHitScan

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.

Instance Counts

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

Element class properties have the prefix hitScan. or hitScan({id}). if id is not empty.

range

Set test range.

offset

Set test origin offset.

origin

Set test origin.

direction

Set test direction.

orientation

Set test orientation.

bone

Set test bone.

Events

This behavior has no events

Required Behaviors

Optional Behaviors

Persistency

This behavior does support element class to be persistable (setPersistable). Saves selected color.

API Documentation

ECBehaviorHitScan.

Since DragonScript Module Version 1.0

Use Cases

Element Class Example

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

Behavior Factory

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>

Live Examples