Traps don't hit actors playing Idle animations, video+code i

Post » Mon Nov 26, 2012 1:16 am

Basically, what it says in the title. If an Actor is in the midst of an Idle animation, such as standing at attention, sitting and eating, etc, physics traps pass through them like ghosts.

Here's a video:
http://www.youtube.com/watch?v=YJir9xaWXGo

You can see the first guard gets hit, but the second one (playing an Idle) isn't. If I break him out of the Idle by starting combat with him, he gets hit just fine.

The flying boulder is a duplicate of the TrapFallingRockSm01 activator. Here's its attached code, modified from PhysicsTrapHit.psc:
Spoiler

Scriptname ELEM_Earth_StoneBoltRockTrapHit extends TrapHitBase;;;;=========================================import utilityHazard Property FXHavokRockHazard AutoExplosion Property HavokRocksixplosion Autofloat property damageVelocityThreshold = 6.0 auto{This sets the velocity needed to apply damageIt is non-squareroot of the delta velocity as recieved from the TrapHitDefault = 6.0This should NOT be changed on the Ref except in rare cases}Auto state CanHitEvent OnTrapHitStart(ObjectReference akTarget, float afXVel, float afYVel, float afZVel, float afXPos, float afYPos, float afZPos, int aeMaterial, bool abInitialHit, int aeMotionType)  ;goToState("CannotHit")  if acceptableVelocityDelta(damageVelocityThreshold, afXVel, afYVel, afZVel);	akTarget.ProcessTrapHit(self, damage, trapPushBack, afXVel, afYVel, afZVel, afXPos, afYPos, afZPos, aeMaterial, staggerAmount)	if TrapHitSound	 TrapHitSound.play(akTarget as ObjectReference)  ;play hit sound	endif	If akTarget as Actor != None	 GotoState("CannotHit")	 Self.PlaceAtMe(HavokRocksixplosion).SetScale(0.5)	 Self.PushActorAway(akTarget as Actor,5)	 Self.Disable(0)	EndIf	;hitFX.fire(self, hitFxAmmo)	CreateDetectionEvent(akTarget as actor, soundLevel) ; creates a detection event  endif  endEventendStatestate CannotHitEvent OnTrapHit(ObjectReference akTarget, float afXVel, float afYVel, float afZVel, float afXPos, float afYPos, float afZPos, int aeMaterial, bool abInitialHit, int aeMotionType)endEventendStatebool function acceptableVelocityDelta(float targetVelocity, float afXVel, float afYVel, float afZVel)float actualDeltaVelocityfloat xyDelta;xyDelta = math.sqrt(math.pow(afXVel, 2) + math.pow(afYVel, 2));actualDeltaVelocity = math.sqrt(math.pow(xyDelta, 2) + math.pow(afZVel, 2));actualDeltaVelocity = (math.abs(afxVel) + math.abs(afYVel) + math.abs(afZVel))actualDeltaVelocity = ((afxVel * afxVel) + (afyVel * afyVel) + (afZVel * afZVel))if actualDeltaVelocity >= targetVelocity;   debug.trace(self + " actualVelocity >= targetVelocity");   debug.trace(self + " deltaX = " + afXVel);   debug.trace(self + " deltaY = " + afYVel);   debug.trace(self + " deltaZ = " + afZVel);   debug.trace(self + " targetVelocity = " + targetVelocity);   debug.trace(self + " totalDelta = " + actualDeltaVelocity)  return TrueElse;   debug.trace(self + " actualVelocity < targetVelocity");   debug.trace(self + " deltaX = " + afXVel);   debug.trace(self + " deltaY = " + afYVel);   debug.trace(self + " deltaZ = " + afZVel);   debug.trace(self + " targetVelocity = " + targetVelocity);   debug.trace(self + " totalDelta = " + actualDeltaVelocity)  return FalseendifendFunction

The other attached script is PhysicsTrap.psc with sane values.

Anyone have any idea what causes this or whether it can be worked around?
User avatar
Trent Theriot
 
Posts: 3395
Joined: Sat Oct 13, 2007 3:37 am

Return to V - Skyrim