KConstraint
KConstraints are a special type of Karma object that can be used in conjunction with actions using PHYS_Karma to make more realistic and more believable simulations. They enforce a relationship between two actors, or between an actor and the world, as well as enforcing a relationship between themselves and the actors that they constrain.
KConstraints have a number of parameters, but are largely self-contained. Setting up a KConstraint generally involves setting as few as 1 parameter, in addition to setting the constraints location and rotation. In game, the constraint will automatically follow the things that it constrains, to keep the relationship between the actors the same.
Quick Start
The best way to learn about Karma constraints is to experiment. Place a couple of KActors and practice constraining them together different ways and with different parameters. To set up a constraint in the editor, simply place the constraint where you would like it, rotate it to the appropriate heading, and set KConstraintActor1 and KConstraintActor2 in the actor properties window. From there you can experiment without really worrying about breaking anything, or you can look at the individual constraint pages for a description of the parameters if experimentation is not your thing.
Properties
Karmaconstraint
- bool bKDisableCollision
- If true, collision between the joined KActors will be disabled as long as those actors are still constrained by this constraint. This is done natively and has no effect on the bKBlockKarma setting or the KEnableCollision/KDisableCollision functions.
- Actor KConstraintActor1 & Actor KConstraintActor2
- These are references to the two actors that will be constrained by this constraint. The order makes no difference, with one exception: If you wish to constrain an actor to the world instead of to another actor, set KConstraintActor2 to None. If you set KConstraintActor1 to None, the constraint will have no effect. Other than constraining actors to the world, the order makes no difference.
- name KConstraintBone1 & name KConstraintBone2
- These are the bones inside KConstraintActor1 and KConstraintActor2 (respectively) that you would like to constrain. If left blank, the location and rotation of the actor overall (the "root" location and rotation) is used.
- float KForceThreshold
- If this value is not zero, the KForceExceed event will be called when the linear force between the actors constrained exceeds this threshold. The force is measured as the force attempting to pull the actors apart.. usually this would be used as the "breaking point" of a constraint. You will have to write your own subclass of the constraint you want to use in order to use this event, however.
Hidden
- bool bKForceFrameUpdate
- Constraints keep track of the things the constrain internally relative to themselves. The "local reference frame" pertains to this relative information. Setting this variable to true, either through script or through the "set" console command, will force the constraint to recalculate it's "local reference frame" based on it's location/rotation and the location/rotation of the actors it constraints, using world coordinates. This is generally left false, as the editor does this automatically whenever you change a variable in the constraint. It is not done automatically if you simply move the constraint, so you must change some variable (you can change it and then change it right back if you like) after moving or rotating the constraint to force it to update it's "local reference frame." If you are going to spawn an actor in-game it is recommended you set this to true.
- int KConstraintData
- This is an internal variable and should not be changed. It refers internally to the set of constraint datas that belong to this actor. (internal constraint data is not stored with the actor inside the Karma engine, so this points to the constraint data that this actor "owns.")
The Local Reference Frame
These variables define the "local reference frame" described under bKForceFrameUpdate. If you do not want to use bKForceFrameUpdate you can set these manually through script. All values are in Karma units. Manually setting these can produce more complex simulation, but such simulation, while more complex, is far less realistic.
- vector KPos1
- Position of KConstraintActor1 relative to the constraint.
- vector KPriAxis1
- Primary axis on which this constraint acts on KConstraintActor1, if applicable.
- vector KSecAxis1
- Secondary axis on which this constraint acts on KConstraintActor1, if applicable.
- vector KPos2
- Position of KConstraintActor2 relative to the constraint.
- vector KPriAxis2
- Primary axis on which this constraint acts on KConstraintActor2, if applicable.
- vector KSecAxis2
- Secondary axis on which this constraint acts on KConstraintActor2, if applicable.