{{tag>dragonscript behavior}}
[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorHitScan**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== 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.
* Full name: ''hitScan.range'' or ''hitScan({id}).range''
* Type: float
* Default Value: 20
* Restriction: At least 0
* Example (*.deeclass) 0.5
===== offset =====
Set test origin offset.
* Full name: ''hitScan.offset'' or ''hitScan({id}).offset''
* Type: float
* Default Value: 0
* Restriction: At least 0
* Example (*.deeclass) 0.5
===== origin =====
Set test origin.
* Full name: ''hitScan.origin'' or ''hitScan({id}).origin''
* Type: 3-component float vector
* Default Value: (0,0,0)
* Example (*.deeclass)
===== direction =====
Set test direction.
* Full name: ''hitScan.direction'' or ''hitScan({id}).direction''
* Type: 3-component float vector
* Default Value: (0,0,1)
* Example (*.deeclass)
===== orientation =====
Set test orientation.
* Full name: ''hitScan.orientation'' or ''hitScan({id}).orientation''
* Type: 3-component float vector
* Default Value: (0,0,0)
* Example (*.deeclass)
===== bone =====
Set test bone.
* Full name: ''hitScan.bone'' or ''hitScan({id}).bone''
* Type: string
* Default Value: empty string
* Example (*.deeclass) value
====== Events ======
This behavior has no events
====== Required Behaviors ======
* [[behavior_collider|ECBehaviorCollider]]: Collider to attach tests to.
====== Optional Behaviors ======
* [[behavior_component|ECBehaviorComponent]]: Required if collision test has to originate from bone.
====== Persistency ======
This behavior does support element class to be persistable (setPersistable). Saves selected color.
====== API Documentation ======
#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorHitScan.html,ECBehaviorHitScan~@#.
Since DragonScript Module Version ''1.0''
====== Use Cases ======
* Line of sight tests.
* Test if a weapon hits a target.
====== 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:
second
1:0 1 2
50
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]