Announcement

Collapse
No announcement yet.

Pawns and karma/kat?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Pawns and karma/kat?

    Anyone know if it is possible to have a Karma controlled object attached to a player character model? What i mean is something like a cape, ponytale, maybee belt of somekind aso that would move as it was a ragdoll and therefor affected by physics engine while playing?

    One would of course have to set up collision for the appropriate bones via KAT and create a specific .ka solution for that model, but thats another issue.

    I think i read somewhere that some of the orginal characters already have a setup close to the one iam describeing? If so anyone know which character uses such a setup? So one could have a look and maybee learn how to set something up.

    Posted this in the L/E section of the forums as well, but since iam quite sure that it will require some coding i might as well try it here to.

    /Matte

    #2
    i kno what ur talking about, i kno it can be done, i'm unfamilliar with kat, and don't kno how to directly help u.

    Though I can say that the tail, ponytail, and any other misc dangley things are cleverly controlled through the animation sets, so they only appear to be moving with real physics.

    Comment


      #3
      Kat is just the program that one uses to create the collisionvolumes for the indivudual bones for karma physics. So to create the .ka file does not involve any codeing.

      The idea that i had in mind is that on actually make a seperate .ukx for the ponytail/tail or whatever. Make a seperate .ka file for this. Set the tail physis variable to PHYS_Karma (or whatever it need to be to work properly, cant remember exactly), then attach it to the rest of the playermodel.

      The implementation is probably more advanced, but thats the basic idea anyway.

      /Matte

      Comment


        #4
        Has anyone created or new karma model (pawn) with 2004 using Kat.

        I've made a new player model but I can't get karma bone constraints to work. The model rag dolls but collapses with arms and legs acting as if they have no constraints on them.

        Here is my code trying to do this if case anyone is interested.


        Code:
        function DoRagdollPhysics( vector Momentum, vector CollisionLocation )
        {
        
        	local vector shotDir, hitLocRel, deathAngVel, shotStrength;
        	local float maxDim;
        	local string RagSkelName;
        	local KarmaParamsSkel skelParams;
        
        	bCanTeleport = false;
        	bReplicateMovement = false;
        	bTearOff = true;
        	bPlayedDeath = true;
        
        	if( RagdollOverride != "")
        	{
        		RagSkelName = RagdollOverride;
        	}
        	else
        	{
        		log("~~No RagdollOverride!!!");
        	}
        
        	// If we managed to find a name, try and make a rag-doll slot availbale.
        	if( RagSkelName != "" )
        	{
        		log("-----");
        		KMakeRagdollAvailable();
        		log("=====");
        	}
        
        	if( KIsRagdollAvailable() && RagSkelName != "" )
        	{
        		log("+++++");
        
        		skelParams = KarmaParamsSkel(KParams);
        		skelParams.KSkeleton = RagSkelName;
        
        		// Stop animation playing.
        		StopAnimating(true);
        
        		// Set the dude moving in direction he was shot in general
        		shotDir = Normal(Momentum);
        		shotStrength = RagDeathVel * shotDir;
        
        		// Calculate angular velocity to impart, based on shot location.
        		hitLocRel = CollisionLocation - Location;
        
        		// We scale the hit location out sideways a bit, to get more spin around Z.
        		hitLocRel.X *= RagSpinScale;
        		hitLocRel.Y *= RagSpinScale;
        
        		// If the tear off momentum was very small for some reason, make up some angular velocity for the pawn
        		if( VSize(Momentum) < 0.01 )
        		{
        			//Log("TearOffMomentum magnitude of Zero");
        			deathAngVel = VRand() * 18000.0;
        		}
        		else
        		{
        			deathAngVel = RagInvInertia * (hitLocRel Cross shotStrength);
        		}
        
        		// Set initial angular and linear velocity for ragdoll.
        		// Scale horizontal velocity for characters - they run really fast!
        		skelParams.KStartLinVel.X = 0.6 * Velocity.X;
        		skelParams.KStartLinVel.Y = 0.6 * Velocity.Y;
        		skelParams.KStartLinVel.Z = 1.0 * Velocity.Z;
        		skelParams.KStartLinVel += shotStrength;
        
        		// If not moving downwards - give extra upward kick
        		if(Velocity.Z > -10)
        		{
        			skelParams.KStartLinVel.Z += RagDeathUpKick;
        		}
        
        		skelParams.KStartAngVel = deathAngVel;
        
        		// Set up deferred shot-bone impulse
        		maxDim = Max(CollisionRadius, CollisionHeight);
        
        		skelParams.KShotStart = TakeHitLocation - (1 * shotDir);
        		skelParams.KShotEnd = TakeHitLocation + (2*maxDim*shotDir);
        		skelParams.KShotStrength = RagShootStrength;
        
        		// Turn on Karma collision for ragdoll.
        		KSetBlockKarma(true);
        
        		// Set physics mode to ragdoll.
        		// This doesn't actaully start it straight away, it's deferred to the first tick.
        		SetPhysics(PHYS_KarmaRagdoll);
        	}
        	else
        	{
        		log("~~ Ragdoll not initialized!");
        	}

        Code:
        	RagdollOverride="Akila"
        
        	Begin Object Class=KarmaParamsSkel Name=PawnKParams0
        		KFriction=0.6
        		KRestitution=0.3
        		KAngularDamping=0.05
        		KLinearDamping=0.15
        		KBuoyancy=1
        		KStartEnabled=True
        		KImpactThreshold=500
        		KVelDropBelowThreshold=50
        		KConvulseSpacing=(Min=0.5,Max=2.2)
        		bHighDetailOnly=False
        		Name="PawnKParams0"
        	End Object
        	KParams=KarmaParams'PawnKParams0'
        
        	RagdollLifeSpan=999
        	RagDeathVel=200
        	RagInvInertia=4
        	RagShootStrength=8000
        	RagSpinScale=2.5
        	RagDeathUpKick=150

        Comment

        Working...
        X