| Home Page | Recent Changes | Preferences

Karma Functions And Events

Below is a listing of the Karma related functions and events. There is a great number of them but most are not particularly useful except in rare circumstances. It is worth noting that these functions often distinguish between "rigid body" Karma objects and Karma ragdolls. A "rigid body" Karma object is essentially and Karma simulated actor that is set to PHYS_Karma, as opposed to PHYS_KarmaRagdoll.

native final function quat KGetRBQuaternion();
Returns a quaternion describing the rotation of a rigid body Karma simulated object.
native final function KGetRigidBodyState(out KRigidBodyState RBstate);
Gets the "state" of a Karma rigid body. This is used primarily for replication. The state includes such things as rotation, velocity, etc. and is used primarily for replication.
native final function KDrawRigidBodyState(KRigidBodyState RBState, bool AltColour);
A slow function. Draws stuff on the screen for debugging Karma rigid bodies. I would not recommend this even for debugging.
native final function vector KRBVecToVector(KRBVec RBvec);
Converts an RBVec to a regular vector. RBVects are more precise than regular vectors and are used primarily for replication.
native final function KRBVec KRBVecFromVector(vector v);
Converts a vector to an RBVec. This is used primarily for replication.
native final function KSetMass( float mass );
Sets the mass of a Karma simulated object. This sets the "KMass" of that object. The regular mass is unaffected.
native final function float KGetMass();
Returns the KMass of a Karma simulated object, in Karma units.
native final function KSetInertiaTensor( vector it1, vector it2 );
Sets the inertia tensor. Unfortunately I don't know what that is. :P
native final function KGetInertiaTensor( out vector it1, out vector it2 );
Reads the inertia tensor and returns it in the two "out" arguments.
native final function KSetDampingProps( float lindamp, float angdamp );
Sets the linear and angular damping properties of a Karma simulated actor.
native final function KGetDampingProps( out float lindamp, out float angdamp );
Puts the current Linear and Angular damping properties into the two out arguments passed to this function.
native final function KSetFriction( float friction );
Sets the friction of a Karma simulated object. This applies only to surface to surface contact, and has no effect on the air resistance.
native final function float KGetFriction();
Returns the friction, in Karma units.
native final function KSetRestitution( float rest );
Sets the elasticity of this object for collisions. 1 is perfectly elastic, 0 is perfectly solid.
native final function float KGetRestitution();
Returns the elasticity of this object.
native final function KSetCOMOffset( vector offset );
Sets the center of mass of this object, relative to it's center.
native final function KGetCOMOffset( out vector offset );
Puts the center of mass of this object, relative to it's center, into the out argument supplied.
native final function KGetCOMPosition( out vector pos );
Similar to KGetCOMPosition, this sets the argument to the absolute location of the Center of mass, relative to the center of the world.
native final function KSetImpactThreshold( float thresh );
Sets the amount of momentum that must be imparted to this object in a single collision in order to trigger it's KImpact event.
native final function float KGetImpactThreshold();
Returns the amount of momentum that must be imparted to this object in a single collision in order to trigger it's KImpact event.
native final function KWake();
"Wakes up" the actor. This causes the Karma physics to begin simulating after the object has been deemed to be "at rest."
native final function bool KIsAwake();
Returns a boolean value stating whether this Karma simulated actor is simulating or not. It returns true if the object is currently simulating, and false if it is "at rest" and has stopped simulating.
native final function KAddImpulse( vector Impulse, vector Position, optional name BoneName );
Imparts an impulse to the Karma actor. Impulse is the amount of force to apply in Karma units. Position is the location that the impulse should be applied, relative to the center of the world. This does not need to actually be in contact with the Karma object. BoneName, if supplied, is the name of the bone that the impulse should be applied to. This only applies to objects with skeletal information.
native final function KSetStayUpright( bool stayUpright, bool allowRotate );
Sets the "stability" of the object. If StayUpright is set to true, the object will not roll or pitch, it will only yaw. If the second argument, AllowRotate, is set to false, the object will not be able to yaw. If it is set to true the object will yaw as normal. If StayUpright is false, AllowRotate will have no effect.
native final function KSetBlockKarma( bool newBlock );
Sets the bBlockKarma value of an actor.
native final function KSetActorGravScale( float ActorGravScale );
Sets the amount that gravity will be scaled by for this actor.
native final function float KGetActorGravScale();
Returns the amount that gravity will be scaled by for this actors simulation.
native final function KDisableCollision( actor Other );
This will selectively disable collision between this Karma object and another given Karma object. Regular collision is not negated, and collision with objects other than those specified is not altered. This function can be called repeatedly to disable collision with an arbitrary number of Karma objects. By default, collision is enabled with all Karma objects.
native final function KEnableCollision( actor Other );
This will selectively enable collision between this Karma object and another given Karma object. Regular collision is not affected, and collision with objects other than those specified is not altered. This function can be called repeatedly to enable collision with an arbitrary number of Karma objects. By default, collision is enabled with all Karma objects.
native final function KSetSkelVel( vector Velocity, optional vector AngVelocity, optional bool AddToCurrent );
Sets the linear, and optionally also an angular velocity for a Karma object with skeletal information attached. If AddToCurrent is true the velocity is added to the current velocity. If AddToCurrent is false, the current velocity is replaced with the one specified to this function.
native final function float KGetSkelMass();
Returns the mass, in Karma units, of a Karma object with skeletal information.
native final function KFreezeRagdoll();
Freezes a Karma ragdoll. This stops it from simulating immediately when this function is called. Note, however, that KIsAwake may not respond to this until the next tick.
native final function KAddBoneLifter( name BoneName, InterpCurve LiftVel, float LateralFriction, InterpCurve Softness );
Adds a "bone lifter." This is used on Karma ragdolls to make it look like a bone is being lifted. This is used on the de-res effect. The bone lifter acts independant of any other forces or velocities acting on the ragdoll. Note that if you do not set bBlockKarma to false before adding bone lifters, you may have erratic results.
native final function KRemoveLifterFromBone( name BoneName );
Removes a bone lifter from whatever bone you specify.
native final function KRemoveAllBoneLifters();
Removes all bone lifters on the actor which calls this function.
native final function KMakeRagdollAvailable();
Allocates a ragdoll. This is used just before creating a ragdoll and will purge the oldest ragdoll if there is not enough room in the ragdoll queue to create another one.
native final function bool KIsRagdollAvailable();
This function checks to see if the ragdoll queue is full. If it is not full, true is returned. If it is full, false is returned. Attempting to create a ragdoll when one is not availible can have unpredictable results. (SimError or simply failure to simulate.)
event KImpact(actor other, vector pos, vector impactVel, vector impactNorm);
This event is called when the momentum imparted to this object from a single collision exceeds the preset impact threshold, KImpactThreshold. This value is in the KarmaParams of the actor. Note that if you destroy an actor within KImpact, it will crash the engine. This appears to be due to the situation where KImpact is called after the list of potentially colliding actors is generated, and destroying something in that list leaves null pointers in said list.

Haral: I've found that if you destroy an actor within KImpact, it will cause the game to crash. I hear this is a known bug (usually referred to as KPerContactCB) but I figured I'd post the obvious hack: Copy the relevant info of what you're going to do into class variables and then just check for the change in Tick() and destroy it there. I think that Epic knows about this and it will probably be fixed when 2k4 comes out.

Foxpaw: Indeed it does. I had the same problem a while ago, but apparently I only squirrelled it away on my developer journal and didn't post it here.

event KVelDropBelow();
This event is called whenever the velocity of the ragdoll drops below a certain threshold which you can set, KVelDropBelowThreshold. This value is in the KarmaParams of the actor.
event KSkelConvulse();
This event is called whenever a KarmaRagdoll Convulses. It is used to draw the lightning effect on the ragdoll but can be used for anything a regular event can be used for.
event KApplyForce(out vector Force, out vector Torque);
This is not an "event" so much, it is called every tick, right before the Karma physics are simulated on this object. It has two "out" variables which allow you to directly apply force and torque to the actor. These values are absolute and will set the value of the force and torque on that actor. Despite the name, the amounts specified are not applied in addition to the existing force and torque, they will overwrite those numbers.
event bool KUpdateState(out KRigidBodyState newState);
This event allows you to manually update the Rigid Body State for a Rigid Body Karma object. I wouldn't particularly recommend using this to set things on a Karma object - KApplyForce, KAddImpulse, etc. are capable of doing the same job with less complication. Regardless of what you set in the newState variable, no changes will take effect if you return false from this function. If you return true, the Karma objects "state" will be replaced with whatever you supplied for the newState argument.

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In