1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Scripting Karma Constraint Woes

Discussion in 'Programming' started by rix, Aug 25, 2004.

  1. rix

    rix New Member

    Joined:
    Jul 22, 2004
    Messages:
    24
    Likes Received:
    0
    I understand that many people have had issues connecting two actors together using KConstraints. The general concensus seems to be that it's just not possible. I have tackled the problem on my own and come up with some promising material. I am, however, out of ideas and only have a partially working solution. It's sort of like a proof of concept.

    Here's what I've been able to accomplish so far (UT2004 - v3270):

    ***From within UnrealED:

    *Imported an SVehicle (the ONSRV).
    *Make sure the Physics is set to PHYS_Karma.
    *Imported the KarmaTube as a ragdoll (from the UDN Karma tutorials).
    *Imported custom characters as ragdolls (generic builds - nothing especially custom).
    *Used KBSJoints to connect the tube and characters to the vehicle.
    *Make sure the Physics is set to PHYS_Karma.
    *Set all KStartEnabled variables to "True".

    *SPECIAL NOTE: The actors won't connect to the vehicle unless the bKDoubleTickRate variable in KarmaParams for all actors involved is the same. Either false or true. I set them all to "True" because SVehicles benefit drastically from the bKDoubleTickRate option. Be careful with this, though, as it can drastically slow down the system with too many actors frequently colliding.

    OUTCOME:
    I was able to run to the car, get in it, and then drive around with the tube swinging behind me and two characters (attached to the wheel axels) dragging behind. When I stop the car, the ragdolls continue to move and can cause my car to flip over (if they have enough combined momentum). It's actually pretty neat: it looks like "Just-Married" cans except it's humans! Heh...

    ***From within Script

    (This is a custom designed trigger - use a generic trigger to cause an event that causes this trigger to trip.)
    *Spawned a weapon.
    *Gave said weapon to the player (using the GiveWeapon function).
    *Gave the weapon some KarmaParams.
    *Set the physics of the weapon to "Karma" (yes, you can do this... the weapon is the first-person model).
    *Using the 'edfindable' modifier, I 'found' a reference to the Tube ragdoll.
    *Spawned a joint (my own class - KBSJoint subclass with bNoDelete set to false by default).
    *Set the Joint's two KConstraintActors to the Tube and the player's weapon.
    *Set the Joint's physics to PHYS_Karma.
    *Called KUpdateConstraintParams() on the joint.

    OUTCOME: When I hit the trigger, the player gets the weapon and the Tube ragdoll twitches a little. One of the joints (the one closest to the player) gets 'kinked' and becomes locked at one angle. Repeated trips of the trigger cause the Tube to become, joint by joint, more tense... all the while jumping around (which causes the ONSRV to buck like a bull). After I've hit the trigger once for each bone in the tube, the Ragdoll is destroyed (log told me so) and a new one is put in. Trip it again and it will crash the game. This isn't of much concern to me for the long run... I'm just playing right now.

    So basically I've gotten to the point where it looks like things get connected briefly and then something goes wrong. As I understand it, KConstraints rely on two things: actors with Bones and PHYS_Karma or PHYS_KarmaRagdoll Physics. The *only* explanation I have for the system breaking is that the weapon's physics may somehow be reverting to PHYS_None or something. In checking the actors variables through "EditActor class='WeaponName'" I haven't noticed a change but I'll try to look into it further.

    Dynamically created joints SHOULD work. They work in KCars for the wheels. I tried KCarWheelJoints for my spawned joint but that didn't change anything. The desired outcome is to get two my player's weapon (and, by extension, the player) tethered to the tube. This SHOULD work in theory as I can 'pin' the tube to the world (the one attached to the car), get in the car and attempt to drive. Everything works, I just can't go beyond the length of the 'leash' I created.

    Anyone see anything? Have any ideas? I'm going to keep working at this but if anyone has any input, that'd be sweet. Thanks!

    I can probably post pictures if you need a better idea of what I'm trying to say...
     
  2. rix

    rix New Member

    Joined:
    Jul 22, 2004
    Messages:
    24
    Likes Received:
    0
    Through doing a little of my own investigation (writing a log command into my Tick Event for my weaponattachment) I found the following:

    * If I don't connect the joint to my WeaponAttachment, then the WeaponAttachment moves with my character (I output the location vector to the log every tick to watch it update location). However,

    * If I attach the joint to my WeaponAttachment and start moving around, the WeaponAttachment disappears from my character (though he can still shoot) and the position never changes more than decimal values - something I'll attribute to animations.

    So it appears that once the weapon attachment gets connected, it gets ripped from the character. Any thoughts on keeping it with him?
     
  3. BinarySystem

    BinarySystem Banned

    Joined:
    Jun 10, 2004
    Messages:
    705
    Likes Received:
    0
    One minor point - I don't believe your weapon attachment is attached to your character karmically - the weapon attachment is normally updated to be "attached" to your character's hand, but moving the weapon attachment should not cause any change in the character. The weapon attachment is more analagous to the trails from the speed adrenaline combo, or a muzzle flash effect.
     
  4. 5parrowhawk

    5parrowhawk New Member

    Joined:
    Sep 17, 2004
    Messages:
    3
    Likes Received:
    0
    WOOHOO!!! IT WORKS!

    Well, sort of.

    I've just created a "Carryall" SCopter in the UE2 runtime which can actually carry another vehicle by attaching it with a KBSJoint. I'd been working on this for awhile, but never realised that I had to set the joint physics and update its params.

    My method was essentially identical to yours, Rix, except that instead of using a search function, I made the vehicle perform a trace to whatever was currently below it. Using this, I have been able to make it pick up the runtime example buggy (by creating a KBSJoint) and drop it off at another location (by destroying the joint).

    The only catch is that my Carryall can no longer lift off when loaded - it can only strafe around :( I'm not sure whether this is related to its thrust and weight values - will have to experiment more. (EDIT: Yes, it's a thrust-related problem. I increased the MaxRiseForce and now it can fly when loaded.) Also, the attached vehicle tends to gyrate weirdly when picked up; I have no idea why.

    Try using 2 vehicles as your attachment points and see what happens. You might be pleasantly surprised!
     
    Last edited: Sep 17, 2004
  5. rix

    rix New Member

    Joined:
    Jul 22, 2004
    Messages:
    24
    Likes Received:
    0
    Yeah, I figured out why it won't work. I don't remember off the top of my head what it was (I'm at home and it's late) but it just won't work when trying to connect it to the player's weapon. So I figured that I'd try to make a vehicle that actually looked just like the player and had all of the player's movement characteristics with the weapon as the vehicles turret. That way the thing would *appear* to be a vehicle attached to a Karma actor attached to a player and not Vehicle - Karma actor - Vehicle (which I know works).

    I'm going to give that a shot when I get back to work next week. :)
     
  6. 5parrowhawk

    5parrowhawk New Member

    Joined:
    Sep 17, 2004
    Messages:
    3
    Likes Received:
    0
    Hmm. Sorry to have raised your hopes then. I misinterpreted what you said to mean that you couldn't get vehicle-object links working outside the editor.

    Instead of doing it that way, have you thought about making an actual player pawn with Karma physics? It seems to me that you could do it that way and it would work - just set it up such that firing that particular weapon would attach the Tube ragdoll to the player with a KBSJoint.

    Or am I completely mistaken again?

    Edit: Hang on; are you sure that attachments (like turrets) with PHYS_Karma work properly? When I was building my Carryall, I tried using AttachToBone to attach a vehicle to the Carryall's "grab point", but it didn't work. The vehicle's mesh appeared to follow the carryall, but its collision boxes, entry points, etc. were left behind - and I'm pretty sure its Karma collision hull was left behind too.
     
    Last edited: Sep 18, 2004

Share This Page