{{tag>dragonscript behavior}} [[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[dragengine:modules:dragonscript:abstractions|Abstraction Layers: How you want to build your Game]] >> [[dragengine:modules:dragonscript:behavior_elements|Behavior Elements]] >> **ECBehaviorRandomizeGeometry** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== ECBehaviorRandomizeGeometry ====== Behavior adding support to randomize position, rotation and scaling. This behavior is typically used to add variation to multiple instances of the same element added to a game world by randomizing the position, rotation and scaling before creating the element. This behavior uses #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1BehaviorPrepareStub.html,BehaviorPrepareStub~@# to apply the changes before the element is actually created. No randomizing is done if the element is created while loading a game world. ====== Instance Counts ====== This behavior can be used only once on an element. ====== Element Class Properties ====== Element class properties have the prefix ''randomizeGeometry.''. ===== randomize ===== Set enable randmoize. * Full name: ''randomizeGeometry.randomize'' or ''randomizeGeometry({id}).randomize'' * Type: boolean * Default Value: true * Example (*.deeclass) false ===== minTranslate ===== Set minimum translation that can be randomly selected. * Full name: ''randomizeGeometry.minTranslate'' or ''randomizeGeometry({id}).minTranslate'' * Type: 3-component float vector * Default Value: (0,0,0) * Example (*.deeclass) ===== maxTranslate ===== Set maximum translation that can be randomly selected. * Full name: ''randomizeGeometry.maxTranslate'' or ''randomizeGeometry({id}).maxTranslate'' * Type: 3-component float vector * Default Value: (0,0,0) * Example (*.deeclass) ===== minRotate ===== Set minimum rotation in degrees that can be randomly selected. * Full name: ''randomizeGeometry.minRotate'' or ''randomizeGeometry({id}).minRotate'' * Type: 3-component float vector * Default Value: (0,0,0) * Example (*.deeclass) ===== maxRotate ===== Set maximum rotation in degrees that can be randomly selected. * Full name: ''randomizeGeometry.maxRotate'' or ''randomizeGeometry({id}).maxRotate'' * Type: 3-component float vector * Default Value: (0,0,0) * Example (*.deeclass) ===== minScale ===== Set minimum scaling that can be randomly selected. * Full name: ''randomizeGeometry.minScale'' or ''randomizeGeometry({id}).minScale'' * Type: 3-component float vector * Default Value: (1,1,1) * Example (*.deeclass) ===== maxScale ===== Set maximum scaling that can be randomly selected. * Full name: ''randomizeGeometry.maxScale'' or ''randomizeGeometry({id}).maxScale'' * Type: 3-component float vector * Default Value: (1,1,1) * Example (*.deeclass) ====== Events ====== This behavior has no events. ====== Required Behaviors ====== This behavior requires no other behaviors. ====== Optional Behaviors ====== This behavior does not support optional behaviors. ====== Persistency ====== This behavior does not required element class to be persistable (setPersistable). ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorRandomizeGeometry.html,ECBehaviorRandomizeGeometry~@#. Since DragonScript Module Version ''1.23'' ====== Use Cases ====== * Randomize positon, rotation and scaling of an element each time the element is added to a game world. ====== Element Class Example ====== This example defines an element which is element with randomized geometry parameters. class MyElement extends BehaviorElementClass public var ECBehaviorRandomizeGeometry randomizeGeometry func new() randomizeGeometry = ECBehaviorRandomizeGeometry.new(this) randomizeGeometry.getMinRotate().setVector(Vector.new(0, -45, 0)) randomizeGeometry.getMaxRotate().setVector(Vector.new(0, 45, 0)) end end ====== Behavior Factory ====== Using element class supporting adding behaviors the behavior can be added like this: ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]