Announcement

Collapse
No announcement yet.

KAddImpulse: What am I doing wrong?

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

    KAddImpulse: What am I doing wrong?

    I'm trying to push a Karma object into the right place. Right now, I'm trying to get any reaction whatsoever from this thing.

    In the first part, I'm calculating how much to push. It's the wrong number, since I have to get a feel for Karma first, but the direction is correct, since when I just move it, it works fine. Once I get a feel for Karma, I'll just change that part to rotate the direction to the opposite actor.

    In the second part, I'm making the actual push. I know it goes into that part because of the log, and when I use move instead of KAddImpulse it works fine.

    When I run this code, however, nothing happens. Right now, I'm trying to impulse a ragdoll, if that helps.

    Code:
     simulated function constrain()
     {
      local float distSquared;
      local vector delta;
    
    //*********** FIRST PART ************
    
    distSquared=((Instigator.Location-victim.Location)Dot Instigator.Location-victim.Location));
      if(Role==ROLE_Authority)
      {
       log("MaxDistSquared"@maxDistSquared@"vs DistSquared"@distSquared);
       if(distSquared>maxDistSquared)
       {
        //constrain by calculating jerk
        delta=(Instigator.location)-(victim.location);
        delta*=(maxDistSquared/((delta dot delta)+maxDistSquared)-0.5);
        delta*=10000;
        jerkVictim=-delta;
        jerkinst=delta;
       }
       else
       {
        jerkVictim=vect(0,0,0);
        jerkInst=vect(0,0,0);
       }
      }
    
    //*********** SECOND PART ************
      if(jerkVictim!=vect(0,0,0))
      {
       victim.KWake();
       victim.KAddImpulse(jerkVictim, Instigator.location); //Apply the impulse
    //   victim.move(jerkVictim);
       log("JERK Victim");
      }
    //  if(jerkInst!=vect(0,0,0)) Instigator.KAddImpulse(delta, self.location);
     }
    Thanks,
    PG

    #2
    Prob. not much help but I noticed that I had to bump up the first val of KAddImpulse(delta, self.location);

    ie. KAddImpulse(delta*100, self.location);

    to get any thing moving. Karma is on a different scale.

    Comment


      #3
      Yah I tried that, but still no dice. It baffles me.

      Comment


        #4
        Just an update, since I fixed my problem. So if anybody had a similar problem this may help.

        IF you're KAddImpulse-ing a ragdoll, you can't just push "the actor" you have to push a specific bone.

        So in my code I have an if statement that checks if the physics mode is PHYS_Karma or PHYS_KarmaRagdoll:
        Code:
        if (victim.Physics==PHYS_KarmaRagdoll)
            victim.KAddimpulse(jerkVictim, location, victim.GetClosestBone(location, Normal(jerkVictim), Dummy))
        else
            victim.KAddimpulse(jerkVictim, location)
        So if you guys are having problems pushing a ragdoll around, there's the solution.

        Comment

        Working...
        X