Entity.create(listOf(
ConeTwistConstraint(
bodyA = torso,
bodyB = upperArm,
anchorA = Vector3(0.3f, 0.5f, 0f), // Shoulder position
anchorB = Vector3(0f, 0.15f, 0f), // Top of arm
twistAxis = Vector3(0f, -1f, 0f), // Arm points down
swingSpan1 = 1.57f, // 90 degrees forward/back
swingSpan2 = 1.05f, // 60 degrees side-to-side
twistSpan = 0.79f // 45 degrees twist
)
))
class ConeTwistConstraint(bodyA: Entity = Entity.nullEntity(), bodyB: Entity = Entity.nullEntity(), anchorA: Vector3 = Vector3(0.0f, 0.0f, 0.0f), anchorB: Vector3 = Vector3(0.0f, 0.0f, 0.0f), breakForce: Float = 0.0f, breakTorque: Float = 0.0f, isBroken: Boolean = false, twistAxis: Vector3 = Vector3(0.0f, 1.0f, 0.0f), swingSpan1: Float = 1.57079f, swingSpan2: Float = 1.57079f, twistSpan: Float = 3.14159f, softness: Float = 1.0f, biasFactor: Float = 0.3f, relaxationFactor: Float = 1.0f, motorEnabled: Boolean = false, motorTargetVelocity: Float = 0.0f, motorMaxForce: Float = 0.0f) : ComponentBase
ConeTwistConstraint
(
bodyA
, bodyB
, anchorA
, anchorB
, breakForce
, breakTorque
, isBroken
, twistAxis
, swingSpan1
, swingSpan2
, twistSpan
, softness
, biasFactor
, relaxationFactor
, motorEnabled
, motorTargetVelocity
, motorMaxForce
)
|
Signature
constructor(bodyA: Entity = Entity.nullEntity(), bodyB: Entity = Entity.nullEntity(), anchorA: Vector3 = Vector3(0.0f, 0.0f, 0.0f), anchorB: Vector3 = Vector3(0.0f, 0.0f, 0.0f), breakForce: Float = 0.0f, breakTorque: Float = 0.0f, isBroken: Boolean = false, twistAxis: Vector3 = Vector3(0.0f, 1.0f, 0.0f), swingSpan1: Float = 1.57079f, swingSpan2: Float = 1.57079f, twistSpan: Float = 3.14159f, softness: Float = 1.0f, biasFactor: Float = 0.3f, relaxationFactor: Float = 1.0f, motorEnabled: Boolean = false, motorTargetVelocity: Float = 0.0f, motorMaxForce: Float = 0.0f) Parameters breakForce: Float
: Force threshold to break constraint (0 = unbreakable)
breakTorque: Float
: Torque threshold to break constraint (0 = unbreakable)
isBroken: Boolean
: Runtime state indicating if constraint has broken (read-only)
swingSpan1: Float
: Maximum swing angle on first axis in radians (perpendicular to twist)
swingSpan2: Float
: Maximum swing angle on second axis in radians (perpendicular to both)
twistSpan: Float
: Maximum twist angle around twist axis in radians
softness: Float
: Constraint softness (0-1, higher = softer)
biasFactor: Float
: Error correction factor (0-1, higher = faster correction)
relaxationFactor: Float
: Constraint relaxation (0-1, higher = more relaxed)
motorEnabled: Boolean
: Whether motor is active for twist axis
motorTargetVelocity: Float
: Target angular velocity for twist in rad/s
motorMaxForce: Float
: Maximum torque motor can apply in Nm
Returns ConeTwistConstraint |
anchorA
: Vector3
[Get][Set] |
Anchor point in local space of bodyA
Signature
var anchorA: Vector3 |
anchorB
: Vector3
[Get][Set] |
Anchor point in local space of bodyB
Signature
var anchorB: Vector3 |
biasFactor
: Float
[Get][Set] |
Error correction factor (0-1, higher = faster correction)
Signature
var biasFactor: Float |
bodyA
: Entity
[Get][Set] |
First physics body (required, must have Physics component)
Signature
var bodyA: Entity |
bodyB
: Entity
[Get][Set] |
Second physics body (null = world anchor)
Signature
var bodyB: Entity |
breakForce
: Float
[Get][Set] |
Force threshold to break constraint in Newtons (0 = unbreakable)
Signature
var breakForce: Float |
breakTorque
: Float
[Get][Set] |
Torque threshold to break constraint in Nm (0 = unbreakable)
Signature
var breakTorque: Float |
cachable
: BuildConfig.COMPONENTCACHE_LEVEL >= 1
[Get][Set] |
Signature
open override var cachable: BuildConfig.COMPONENTCACHE_LEVEL >= 1 |
entID
: Long
[Get][Set] |
Signature
var entID: Long |
isBroken
: Boolean
[Get][Set] |
Runtime state: true if constraint has exceeded breaking threshold
Signature
var isBroken: Boolean |
isDirty
: Boolean
[Get][Set] |
Signature
var isDirty: Boolean |
motorEnabled
: Boolean
[Get][Set] |
Whether motor is active for twist axis
Signature
var motorEnabled: Boolean |
motorMaxForce
: Float
[Get][Set] |
Maximum torque motor can apply in Nm
Signature
var motorMaxForce: Float |
motorTargetVelocity
: Float
[Get][Set] |
Target angular velocity for twist in rad/s
Signature
var motorTargetVelocity: Float |
recycled
: Boolean
[Get][Set] |
Signature
var recycled: Boolean |
relaxationFactor
: Float
[Get][Set] |
Constraint relaxation factor (0-1, higher = more relaxed)
Signature
var relaxationFactor: Float |
softness
: Float
[Get][Set] |
Constraint softness (0-1, higher = softer limits)
Signature
var softness: Float |
swingSpan1
: Float
[Get][Set] |
Maximum swing angle on first axis in radians (PI/2 = 90 degrees)
Signature
var swingSpan1: Float |
swingSpan2
: Float
[Get][Set] |
Maximum swing angle on second axis in radians (PI/2 = 90 degrees)
Signature
var swingSpan2: Float |
timeStamp
: Long
[Get][Set] |
Signature
var timeStamp: Long |
twistAxis
: Vector3
[Get][Set] |
Primary axis around which twisting occurs (in local space of bodyA)
Signature
var twistAxis: Vector3 |
twistSpan
: Float
[Get][Set] |
Maximum twist angle around twist axis in radians (PI = 180 degrees)
Signature
var twistSpan: Float |
companion
()
|
Gets the companion object for this component.
The companion object provides metadata about the component.
Signature
open override fun companion(): ComponentCompanion Throws RuntimeException
If the companion is not implemented
|
getComponentDataAttributeType
(
key
)
|
Gets the attribute type for the specified key.
Signature
fun getComponentDataAttributeType(key: Int): AttributePrimitive? Parameters key: Int
The integer key to look up
|
getComponentDataAttributeType
(
keyString
)
|
Gets the attribute type for the specified string key.
Signature
fun getComponentDataAttributeType(keyString: String): AttributePrimitive? Parameters keyString: String
The string key to look up
Throws IllegalArgumentException
If the key doesn't exist
|
getComponentDataKey
(
key
)
|
Gets the integer key associated with the specified string key.
Signature
fun getComponentDataKey(key: String): Int? Parameters key: String
The string key to look up
Returns Int?
The integer key, or null if the string key doesn't exist
|
getComponentDataValue
(
key
)
|
Gets the value for the specified key.
Signature
fun getComponentDataValue(key: Int): Any? Parameters key: Int
The integer key to look up
Returns Any?
The value associated with the key, or null if the key doesn't exist
|
getComponentDataValue
(
keyString
)
|
Gets the value for the specified string key.
Signature
fun getComponentDataValue(keyString: String): Any? Parameters keyString: String
The string key to look up
Returns Any?
The value associated with the key, or null if the key doesn't exist
Throws IllegalArgumentException
If the key doesn't exist
|
getEnumClass
(
key
)
|
Gets the enum class associated with the specified string key.
Signature
fun getEnumClass(key: String): Class<out Enum<*>>? Parameters key: String
The string key to look up
Returns Class?
The enum class, or null if the key doesn't exist or is not an enum
|
hasAttributeChanges
()
|
Returns true if any attribute has been modified since the last read/write sync.
This is a read-only check. To clear the flag, call Entity.setComponent which syncs changes to native and resets the dirty state.
Signature
fun hasAttributeChanges(): Boolean Returns Boolean |
hasComponentData
(
key
)
|
Checks if this component has data for the specified key.
Signature
fun hasComponentData(key: Int): Boolean Parameters key: Int
The integer key to check
Returns Boolean
True if the component has data for the key, false otherwise
|
hasComponentData
(
keyString
)
|
Checks if this component has data for the specified string key.
Signature
fun hasComponentData(keyString: String): Boolean Parameters keyString: String
The string key to check
Returns Boolean
True if the component has data for the key, false otherwise
|
read
(
e
, cachable
)
|
Reads component data from the specified entity.
Signature
fun read(e: Entity, cachable: Boolean) Parameters cachable: Boolean
Whether the component's data should be cached
|
recycle
()
|
Recycles this component by returning it to its pool.
If the component has a pool assigned, it will be returned to that pool for reuse.
Signature
fun recycle() |
reset
()
|
Resets the component to its default state.
This method is called when a component is recycled to clear any state. Subclasses should override this method to reset their specific state.
Signature
open fun reset() |
setComponentDataValue
(
key
, value
)
|
Sets the value for the specified key.
Signature
fun setComponentDataValue(key: Int, value: Any): Boolean Parameters key: Int
The integer key to set
value: Any
The value to set
Returns Boolean
True if the value was set successfully, false otherwise
|
setComponentDataValue
(
keyString
, value
)
|
Sets the value for the specified string key.
Signature
fun setComponentDataValue(keyString: String, value: Any): Boolean Parameters keyString: String
The string key to set
value: Any
The value to set
Returns Boolean
True if the key exists and the value was set, false otherwise
|
setPool
(
pool
, entID
)
|
Sets the component pool and entity ID for this component.
This is used for component recycling to track which pool the component belongs to and which entity it was associated with.
Signature
fun setPool(pool: ComponentPool<*>, entID: Long) Parameters pool: ComponentPool
The component pool this component belongs to
entID: Long
The ID of the entity this component is associated with
|
toString
()
|
Signature
open override fun toString(): String Returns String |
typeID
()
|
Returns the unique type ID of this component.
Each component type must have a unique ID for identification in the entity-component system.
Signature
open override fun typeID(): Int Returns Int
The unique type ID for this component
|
write
(
e
)
|
Writes this component's data to the specified entity.
Signature
fun write(e: Entity) Parameters |
anchorAData
: Vector3AttributeData
[Get] |
Signature
val anchorAData: Vector3AttributeData |
anchorAId
:
[Get] |
Signature
val anchorAId: |
anchorBData
: Vector3AttributeData
[Get] |
Signature
val anchorBData: Vector3AttributeData |
anchorBId
:
[Get] |
Signature
val anchorBId: |
attributeKeys_
: IntArray
[Get] |
Signature
val attributeKeys_: IntArray |
attributeTypeCounts_
: IntArray
[Get] |
Signature
val attributeTypeCounts_: IntArray |
attributeTypes_
: IntArray
[Get] |
Signature
val attributeTypes_: IntArray |
attrMetaData_
: Map
[Get] |
Signature
val attrMetaData_: Map |
biasFactorData
: FloatAttributeData
[Get] |
Signature
val biasFactorData: FloatAttributeData |
biasFactorId
:
[Get] |
Signature
val biasFactorId: |
bodyAData
: EntityAttributeData
[Get] |
Signature
val bodyAData: EntityAttributeData |
bodyAId
:
[Get] |
Signature
val bodyAId: |
bodyBData
: EntityAttributeData
[Get] |
Signature
val bodyBData: EntityAttributeData |
bodyBId
:
[Get] |
Signature
val bodyBId: |
breakForceData
: FloatAttributeData
[Get] |
Signature
val breakForceData: FloatAttributeData |
breakForceId
:
[Get] |
Signature
val breakForceId: |
breakTorqueData
: FloatAttributeData
[Get] |
Signature
val breakTorqueData: FloatAttributeData |
breakTorqueId
:
[Get] |
Signature
val breakTorqueId: |
createDefaultInstance
: Function0
[Get] |
Signature
open override val createDefaultInstance: () -> ConeTwistConstraint |
enumClassesMap_
: Map
[Get] |
Signature
val enumClassesMap_: Map<Int, Class<out Enum<*>>> |
id
:
[Get] |
Signature
open override val id: |
isBrokenData
: BooleanAttributeData
[Get] |
Signature
val isBrokenData: BooleanAttributeData |
isBrokenId
:
[Get] |
Signature
val isBrokenId: |
keyStringToKeyIntMap_
: Map
[Get] |
Signature
val keyStringToKeyIntMap_: Map<String, Int> |
motorEnabledData
: BooleanAttributeData
[Get] |
Signature
val motorEnabledData: BooleanAttributeData |
motorEnabledId
:
[Get] |
Signature
val motorEnabledId: |
motorMaxForceData
: FloatAttributeData
[Get] |
Signature
val motorMaxForceData: FloatAttributeData |
motorMaxForceId
:
[Get] |
Signature
val motorMaxForceId: |
motorTargetVelocityData
: FloatAttributeData
[Get] |
Signature
val motorTargetVelocityData: FloatAttributeData |
motorTargetVelocityId
:
[Get] |
Signature
val motorTargetVelocityId: |
relaxationFactorData
: FloatAttributeData
[Get] |
Signature
val relaxationFactorData: FloatAttributeData |
relaxationFactorId
:
[Get] |
Signature
val relaxationFactorId: |
softnessData
: FloatAttributeData
[Get] |
Signature
val softnessData: FloatAttributeData |
softnessId
:
[Get] |
Signature
val softnessId: |
swingSpan1Data
: FloatAttributeData
[Get] |
Signature
val swingSpan1Data: FloatAttributeData |
swingSpan1Id
:
[Get] |
Signature
val swingSpan1Id: |
swingSpan2Data
: FloatAttributeData
[Get] |
Signature
val swingSpan2Data: FloatAttributeData |
swingSpan2Id
:
[Get] |
Signature
val swingSpan2Id: |
twistAxisData
: Vector3AttributeData
[Get] |
Signature
val twistAxisData: Vector3AttributeData |
twistAxisId
:
[Get] |
Signature
val twistAxisId: |
twistSpanData
: FloatAttributeData
[Get] |
Signature
val twistSpanData: FloatAttributeData |
twistSpanId
:
[Get] |
Signature
val twistSpanId: |
attributeKeys
()
|
Signature
open override fun attributeKeys(): IntArray Returns IntArray |
attributeMetaData
()
| Returns Map |
attributeTypeCountAvailable
()
|
Signature
open override fun attributeTypeCountAvailable(): Boolean Returns Boolean |
attributeTypeCounts
()
|
Signature
open override fun attributeTypeCounts(): IntArray Returns IntArray |
attributeTypes
()
|
Signature
open override fun attributeTypes(): IntArray Returns IntArray |
dependents
()
|
Signature
open fun dependents(): IntArray Returns IntArray |
enumClassesMap
()
|
Signature
open override fun enumClassesMap(): Map<Int, Class<out Enum<*>>> Returns Map |
keyStringToKeyIntMap
(
keyString
)
|
Signature
open override fun keyStringToKeyIntMap(keyString: String): Int? Parameters keyString: StringReturns Int? |