News UnrealEd Files Mods FragBU Liandri Archives
BeyondUnreal Forums

Go Back   BeyondUnreal Forums > Unreal Development > Coding

Thread Tools Display Modes
Old 25th Aug 2004, 01:49 PM   #1
Registered User
Join Date: Jul. 22nd, 2004
Posts: 24
Scripting Karma Constraint Woes

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.

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...
rix is offline   Reply With Quote
Old 27th Aug 2004, 10:07 AM   #2
Registered User
Join Date: Jul. 22nd, 2004
Posts: 24
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?
rix is offline   Reply With Quote
Old 30th Aug 2004, 05:27 AM   #3
Join Date: Jun. 10th, 2004
Posts: 705
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.
BinarySystem is offline   Reply With Quote
Old 17th Sep 2004, 11:22 PM   #4
Registered User
Join Date: Sep. 17th, 2004
Posts: 3

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 by 5parrowhawk; 17th Sep 2004 at 11:28 PM.
5parrowhawk is offline   Reply With Quote
Old 17th Sep 2004, 11:53 PM   #5
Registered User
Join Date: Jul. 22nd, 2004
Posts: 24
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.
rix is offline   Reply With Quote
Old 18th Sep 2004, 12:43 AM   #6
Registered User
Join Date: Sep. 17th, 2004
Posts: 3
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 by 5parrowhawk; 18th Sep 2004 at 11:14 AM.
5parrowhawk is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 03:31 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2015, vBulletin Solutions, Inc.

Copyright ©1998 - 2015, BeyondUnreal
Privacy Policy | Terms of Use
Bandwidth provided by AtomicGamer