AddHavokBallAndSocketConstraint - Does this function work at

Post » Thu Jun 21, 2012 4:15 am

I am trying to get a working example of the AddHavokBallAndSocketConstraint() function working. I have a script that has a function that looks like this:

function AttachBook()	bool myAttach = Game.AddHavokBallAndSocketConstraint(FaendalREF, "NPC Neck [Neck]", myBookREF, "Book01")	debug.notification("Attachment is " + myAttach)endFunction

Ridiculous, I know, but it should work. FaendalREF has a NiNode named "NPC Neck [Neck]", and myBookREF, which is a book object reference that is resolved to Book1CheapBriefHistoryoftheEmpirev1, and has a NiNode named "Book01". This should attach the book to Faendal's neck.

When I execute this function, myAttach returns TRUE, but the book never moves and the attachment never appears to take place.

Has anyone ever been able to get this function to work? If so, how?

Thanks!
User avatar
MatthewJontully
 
Posts: 3517
Joined: Thu Mar 08, 2007 9:33 am

Post » Thu Jun 21, 2012 3:44 am

Yes, it certainly does work. However, the nodes referenced must contain a bhkCollisionObject node, which in turn must contain a bhkRigidBody node. Do both the nodes you name have these?
User avatar
NAkeshIa BENNETT
 
Posts: 3519
Joined: Fri Jun 16, 2006 12:23 pm

Post » Thu Jun 21, 2012 4:18 pm

I reworked my example based on your information, and it still doesn't do what it should be. Here is a new function:

function AttachCabbage()    objectreference myCabbage = Game.GetPlayer().PlaceAtMe(FoodCabbage, 1)    bool myAttach = Game.AddHavokBallAndSocketConstraint(Game.GetPlayer(), "NPC Neck [Neck]", myCabbage, "Cabbage01")    debug.notification("Attachment is " + myAttach)endFunction

The cabbage falls to the ground and is not bound to the player's neck, and myAttach is TRUE. Here is a look at each of the NIFs in question.

http://i.imgur.com/BWkHA.jpg

Thanks for the help. I hope you can point out what I'm doing wrong.
User avatar
BrEezy Baby
 
Posts: 3478
Joined: Sun Mar 11, 2007 4:22 am

Post » Thu Jun 21, 2012 4:13 pm

Ok, I got something to work: I was able to successfully add a constraint between a dead actor's hand and another dead actor's hand. I was also able to add a constraint between a dead actor's hand and a cabbage. However, these constraints don't seem to work if the actor is alive.

I'm assuming there's no way to add a constraint between an object and a live actor?

Edit: further testing shows that adding a constraint to a dead actor, and then resurrecting the actor breaks the constraint.
User avatar
Dan Endacott
 
Posts: 3419
Joined: Fri Jul 06, 2007 9:12 am

Post » Thu Jun 21, 2012 7:40 am

Ok, I got something to work: I was able to successfully add a constraint between a dead actor's hand and another dead actor's hand. I was also able to add a constraint between a dead actor's hand and a cabbage. However, these constraints don't seem to work if the actor is alive.
Ah, well spotted. I must admit, I've never tried to use this on an actor. One thing you might try is applying a small Havok impulse (applyHavokImpulse) on the live actor after creating the ball and socket joint, or using a low-power pushActorAway. Getting the actor to rag-doll for a moment might give the physics kick needed to get things going. I spotted this trick being used in a Bethesda script called DefaultRagdollAttachPointSCRIPT.psc; although I don't know if this script is actually used in the game.

Good luck!
User avatar
Scarlet Devil
 
Posts: 3410
Joined: Wed Aug 16, 2006 6:31 pm

Post » Thu Jun 21, 2012 1:05 pm

Tried using PushActorAway; it does the trick until the actor gets completely back up, at which point the object falls off.

The ultimate goal here was to be able to attach objects (weapons, potions, etc) dynamically to the player without the use of Armor objects, but it looks like it's not going to happen. Oh well, this was a good learning experience.

Thanks for the help! I'll note some of this information on the wiki.
User avatar
Nathan Hunter
 
Posts: 3464
Joined: Sun Apr 29, 2007 9:58 am

Post » Thu Jun 21, 2012 12:18 pm

Darth Vader force choke using this, four invisible activators, Translateto, and setunconscious?

Goiog for it.
User avatar
Chantel Hopkin
 
Posts: 3533
Joined: Sun Dec 03, 2006 9:41 am

Post » Thu Jun 21, 2012 5:25 am

A few things there:
1) Set Unconscious does NOT actually knock out a target, it simply raises a flag.
2) Force choke could be accomplished much easier. Just spawn 1 invisible activator above the targets head, do a small PushActorAway and immediately make the actor SplineTranslateToRef to the thing above their head at low speed. OnTranslationComplete Utility.Wait(2), akTarget.KillSilent()
User avatar
Crystal Clarke
 
Posts: 3410
Joined: Mon Dec 11, 2006 5:55 am

Post » Thu Jun 21, 2012 12:37 pm

This thread took an unexpected, but awesome, turn.
User avatar
April D. F
 
Posts: 3346
Joined: Wed Mar 21, 2007 8:41 pm


Return to V - Skyrim