Table of Contents

,

Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorRandomizeGeometry

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 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.

minTranslate

Set minimum translation that can be randomly selected.

maxTranslate

Set maximum translation that can be randomly selected.

minRotate

Set minimum rotation in degrees that can be randomly selected.

maxRotate

Set maximum rotation in degrees that can be randomly selected.

minScale

Set minimum scaling that can be randomly selected.

maxScale

Set maximum scaling that can be randomly selected.

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

ECBehaviorRandomizeGeometry.

Since DragonScript Module Version 1.23

Use Cases

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:

<?xml version='1.0' encoding='UTF-8'?>
<elementClass name='MyClass' class='GenericBehaviorElement'>
  <behavior type='ECBehaviorRandomizeGeometry'>
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <vector name='.minRotate' x='0' y='-45' z='0'/>
    <vector name='.maxRotate' x='0' y='45' z='0'/>
  </behavior>
</elementClass>

Live Examples