@rbxts/falldown 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/index.d.ts +23 -4
- package/out/init.luau +213 -156
- package/package.json +1 -1
package/out/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export interface IActiveRagdoll {
|
|
|
38
38
|
* @see {@linkcode IActiveRagdoll.Destroyed}
|
|
39
39
|
* @see {@linkcode Falldown.UnragdollCharacter}
|
|
40
40
|
*/
|
|
41
|
-
Destroy(): void;
|
|
41
|
+
Destroy(exitMode: (typeof Falldown.ExitMode)[keyof typeof Falldown.ExitMode]): void;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Main Falldown class providing static methods for ragdolling characters in Roblox. Creates realistic ragdoll physics by replacing Motor6Ds with constraints, managing collision groups, and providing smooth getup animations.
|
|
@@ -64,6 +64,19 @@ export declare class Falldown {
|
|
|
64
64
|
/** Each part gets a random velocity from 0 to the specified magnitude in the same direction. Creates varied motion, useful for explosions. */
|
|
65
65
|
readonly RandomMax: 3;
|
|
66
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Enum used to represent how a ragdolled character should exit the ragdoll state.
|
|
69
|
+
* @static
|
|
70
|
+
* @readonly
|
|
71
|
+
* @enum {number}
|
|
72
|
+
* @see {@linkcode IActiveRagdoll.Destroy}
|
|
73
|
+
*/
|
|
74
|
+
static ExitMode: {
|
|
75
|
+
/** Character will play the appropriate getup animation and stand up on their own. Default behavior. */
|
|
76
|
+
readonly Smooth: 0;
|
|
77
|
+
/** Character will be restored at its current exact ragdoll position, standing with no fade or animations */
|
|
78
|
+
readonly Immediate: 1;
|
|
79
|
+
};
|
|
67
80
|
private static readonly _activeRagdolls;
|
|
68
81
|
private static MakeProxies;
|
|
69
82
|
private static CreateActiveRagdollR6;
|
|
@@ -81,7 +94,7 @@ export declare class Falldown {
|
|
|
81
94
|
* @see {@linkcode Falldown.UnragdollCharacter}
|
|
82
95
|
* @see {@linkcode Falldown.VelocityMode}
|
|
83
96
|
*/
|
|
84
|
-
static RagdollCharacter(character: Model, standupFadeTime: number, automaticDuration?: number, getupFront?: Animation, getupBack?: Animation): IActiveRagdoll | undefined;
|
|
97
|
+
static RagdollCharacter(character: Model, standupFadeTime: number, automaticDuration?: number, exitMode?: (typeof Falldown.ExitMode)[keyof typeof Falldown.ExitMode], getupFront?: Animation, getupBack?: Animation): IActiveRagdoll | undefined;
|
|
85
98
|
/**
|
|
86
99
|
* Manually ends the ragdoll state for a specific character. Equivalent to calling {@linkcode IActiveRagdoll.Destroy} on the ragdoll instance. If the character is not currently ragdolled, this method does nothing.
|
|
87
100
|
* @static
|
|
@@ -91,7 +104,13 @@ export declare class Falldown {
|
|
|
91
104
|
* @see {@linkcode Falldown.RagdollCharacter}
|
|
92
105
|
* @see {@linkcode Falldown.UnragdollAllCharacters}
|
|
93
106
|
*/
|
|
94
|
-
static UnragdollCharacter(character: Model, delayTime?: number): void;
|
|
107
|
+
static UnragdollCharacter(character: Model, delayTime?: number, exitMode?: (typeof Falldown.ExitMode)[keyof typeof Falldown.ExitMode]): void;
|
|
108
|
+
/**
|
|
109
|
+
* @static
|
|
110
|
+
* @param character - The character `Model` to check
|
|
111
|
+
* @returns Whether the character is currently ragdolled
|
|
112
|
+
*/
|
|
113
|
+
static IsCharacterRagdolled(character: Model): boolean;
|
|
95
114
|
/**
|
|
96
115
|
* Ends the ragdoll state for ALL currently ragdolled characters. Useful for game-wide effects like round resets or emergency cleanup. Each character performs their getup animation independently.
|
|
97
116
|
* @static
|
|
@@ -99,5 +118,5 @@ export declare class Falldown {
|
|
|
99
118
|
* @see {@linkcode Falldown.UnragdollCharacter}
|
|
100
119
|
* @see {@linkcode Falldown.RagdollCharacter}
|
|
101
120
|
*/
|
|
102
|
-
static UnragdollAllCharacters(delayTime?: number): void;
|
|
121
|
+
static UnragdollAllCharacters(delayTime?: number, exitMode?: (typeof Falldown.ExitMode)[keyof typeof Falldown.ExitMode]): void;
|
|
103
122
|
}
|
package/out/init.luau
CHANGED
|
@@ -374,7 +374,7 @@ do
|
|
|
374
374
|
local self = setmetatable({}, ActiveRagdoll)
|
|
375
375
|
return self:constructor(...) or self
|
|
376
376
|
end
|
|
377
|
-
function ActiveRagdoll:constructor(character, objectiveHeight, standFadeTime, humanoid, humanoidRootPart, leftTouchObj, rightTouchObj, jointDestructionInfo, proxyGroupId, bodypartGroupId, proxyMapping, automaticDuration, getupFront, getupBack)
|
|
377
|
+
function ActiveRagdoll:constructor(character, objectiveHeight, standFadeTime, humanoid, humanoidRootPart, leftTouchObj, rightTouchObj, jointDestructionInfo, proxyGroupId, bodypartGroupId, proxyMapping, automaticDuration, exitMode, getupFront, getupBack)
|
|
378
378
|
self.Destroyed = Signal.new()
|
|
379
379
|
self.Ended = Signal.new()
|
|
380
380
|
character.Destroying:Once(function()
|
|
@@ -417,7 +417,12 @@ do
|
|
|
417
417
|
end
|
|
418
418
|
if _condition ~= 0 and _condition == _condition and _condition then
|
|
419
419
|
delay(self._automaticDuration, function()
|
|
420
|
-
self
|
|
420
|
+
local _self = self
|
|
421
|
+
local _condition_1 = exitMode
|
|
422
|
+
if not (_condition_1 ~= 0 and _condition_1 == _condition_1 and _condition_1) then
|
|
423
|
+
_condition_1 = Falldown.ExitMode.Smooth
|
|
424
|
+
end
|
|
425
|
+
_self:Destroy(_condition_1)
|
|
421
426
|
end)
|
|
422
427
|
end
|
|
423
428
|
end
|
|
@@ -492,7 +497,7 @@ do
|
|
|
492
497
|
end
|
|
493
498
|
end
|
|
494
499
|
end
|
|
495
|
-
function ActiveRagdoll:Destroy(overrideDeathLock)
|
|
500
|
+
function ActiveRagdoll:Destroy(exitMode, overrideDeathLock)
|
|
496
501
|
if self.Character.Parent == nil then
|
|
497
502
|
return nil
|
|
498
503
|
end
|
|
@@ -502,55 +507,7 @@ do
|
|
|
502
507
|
if #self._jointDestructionInfo == 0 or next(self._proxyMapping) == nil then
|
|
503
508
|
return nil
|
|
504
509
|
end
|
|
505
|
-
|
|
506
|
-
clonedCharacter.Name = "Falldown_FadeClone_Temp"
|
|
507
|
-
local humanoid = Instance.new("Humanoid")
|
|
508
|
-
local animator = humanoid:FindFirstChildOfClass("Animator")
|
|
509
|
-
humanoid.RigType = self.Humanoid.RigType
|
|
510
|
-
humanoid.RequiresNeck = false
|
|
511
|
-
humanoid.AutoRotate = false
|
|
512
|
-
if animator then
|
|
513
|
-
for _, anim in animator:GetPlayingAnimationTracks() do
|
|
514
|
-
anim:Stop()
|
|
515
|
-
end
|
|
516
|
-
animator:Destroy()
|
|
517
|
-
end
|
|
518
|
-
local cloneCG = HttpService:GenerateGUID(false)
|
|
519
|
-
PhysicsService:RegisterCollisionGroup(cloneCG)
|
|
520
|
-
PhysicsService:CollisionGroupSetCollidable(cloneCG, "Default", false)
|
|
521
|
-
PhysicsService:CollisionGroupSetCollidable(cloneCG, self._bodypartGroupId, false)
|
|
522
|
-
PhysicsService:CollisionGroupSetCollidable(cloneCG, cloneCG, false)
|
|
523
|
-
local cloneToRealMap = {}
|
|
524
|
-
local originalTransparencies = {}
|
|
525
|
-
for _, descendant in self.Character:GetDescendants() do
|
|
526
|
-
if descendant:IsA("BasePart") then
|
|
527
|
-
local partClone = descendant:Clone()
|
|
528
|
-
partClone.Anchored = true
|
|
529
|
-
partClone.CollisionGroup = cloneCG
|
|
530
|
-
partClone.CFrame = descendant.CFrame
|
|
531
|
-
cloneToRealMap[partClone] = descendant
|
|
532
|
-
local _transparency = descendant.Transparency
|
|
533
|
-
originalTransparencies[descendant] = _transparency
|
|
534
|
-
for _1, partDesc in partClone:GetDescendants() do
|
|
535
|
-
if partDesc:IsA("JointInstance") or partDesc:IsA("Constraint") or partDesc:IsA("Attachment") then
|
|
536
|
-
partDesc:Destroy()
|
|
537
|
-
elseif partDesc:IsA("Decal") then
|
|
538
|
-
local _arg0 = descendant:FindFirstChild(partDesc.Name)
|
|
539
|
-
local _transparency_1 = partDesc.Transparency
|
|
540
|
-
originalTransparencies[_arg0] = _transparency_1
|
|
541
|
-
end
|
|
542
|
-
end
|
|
543
|
-
partClone.Parent = clonedCharacter
|
|
544
|
-
elseif descendant:IsA("Clothing") then
|
|
545
|
-
local clothingClone = descendant:Clone()
|
|
546
|
-
clothingClone.Parent = clonedCharacter
|
|
547
|
-
end
|
|
548
|
-
end
|
|
549
|
-
humanoid.Parent = clonedCharacter
|
|
550
|
-
clonedCharacter.Parent = Workspace
|
|
551
|
-
for thing, originalTransparency in originalTransparencies do
|
|
552
|
-
thing.Transparency = 1
|
|
553
|
-
end
|
|
510
|
+
-- ── Shared: remove ragdoll constraints, restore Motor6Ds ──
|
|
554
511
|
for _, info in self._jointDestructionInfo do
|
|
555
512
|
info.Replaced.Enabled = true
|
|
556
513
|
info.Constraint:Destroy()
|
|
@@ -574,21 +531,12 @@ do
|
|
|
574
531
|
descendant.AssemblyAngularVelocity = Vector3.zero
|
|
575
532
|
end
|
|
576
533
|
end
|
|
577
|
-
|
|
578
|
-
self.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
|
|
579
|
-
self.HumanoidRootPart.Anchored = true
|
|
580
|
-
--const thisAnimator = this.Humanoid.FindFirstChildOfClass("Animator");
|
|
581
|
-
--if (thisAnimator) {
|
|
582
|
-
-- for (const anim of thisAnimator.GetPlayingAnimationTracks()) {
|
|
583
|
-
-- anim.Stop(0);
|
|
584
|
-
-- }
|
|
585
|
-
--}
|
|
534
|
+
-- ── Shared: destroy proxy parts ──
|
|
586
535
|
for _, proxyPart in self._proxyMapping do
|
|
587
536
|
proxyPart:Destroy()
|
|
588
537
|
end
|
|
589
538
|
table.clear(self._proxyMapping)
|
|
590
|
-
|
|
591
|
-
local activeAnimation = nil
|
|
539
|
+
-- ── Shared: raycast for ground & compute stand CFrame ──
|
|
592
540
|
local _cFrame = self.LeftTouchPart.CFrame
|
|
593
541
|
local _cFrame_1 = CFrame.new(0, -(self.LeftTouchPart.Size.Y / 2), 0)
|
|
594
542
|
local leftToes = _cFrame * _cFrame_1
|
|
@@ -660,79 +608,10 @@ do
|
|
|
660
608
|
end
|
|
661
609
|
right = right.Unit
|
|
662
610
|
local forwardOnSurface = right:Cross(groundNormal).Unit
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
end
|
|
668
|
-
task.spawn(function()
|
|
669
|
-
if activeAnimation then
|
|
670
|
-
local targetCFrame = CFrame.fromMatrix(centerPoint, forwardOnSurface, groundNormal)
|
|
671
|
-
self.Character:PivotTo(targetCFrame)
|
|
672
|
-
activeAnimation:Play(0, 1, 0)
|
|
673
|
-
while not activeAnimation.IsPlaying do
|
|
674
|
-
task.wait()
|
|
675
|
-
end
|
|
676
|
-
activeAnimation.TimePosition = 0.0
|
|
677
|
-
task.wait()
|
|
678
|
-
local activeLerp = 0
|
|
679
|
-
task.spawn(function()
|
|
680
|
-
while true do
|
|
681
|
-
local dt = task.wait(1 / 60)
|
|
682
|
-
local lerpAlpha = activeLerp + (dt / math.min(self._standFadeTime, activeAnimation.Length))
|
|
683
|
-
local ended = false
|
|
684
|
-
if lerpAlpha >= 1 then
|
|
685
|
-
ended = true
|
|
686
|
-
lerpAlpha = 1
|
|
687
|
-
end
|
|
688
|
-
for partClone, realPart in cloneToRealMap do
|
|
689
|
-
partClone.CFrame = partClone.CFrame:Lerp(realPart.CFrame, lerpAlpha)
|
|
690
|
-
end
|
|
691
|
-
activeLerp = lerpAlpha
|
|
692
|
-
if ended then
|
|
693
|
-
for partClone, realPart in cloneToRealMap do
|
|
694
|
-
partClone:Destroy()
|
|
695
|
-
end
|
|
696
|
-
for thing, originalTransparency in originalTransparencies do
|
|
697
|
-
thing.Transparency = originalTransparency
|
|
698
|
-
end
|
|
699
|
-
return nil
|
|
700
|
-
end
|
|
701
|
-
end
|
|
702
|
-
end)
|
|
703
|
-
activeAnimation:AdjustSpeed(1)
|
|
704
|
-
activeAnimation.Ended:Wait()
|
|
705
|
-
else
|
|
706
|
-
local targetCFrame = CFrame.fromMatrix(centerPoint, forwardOnSurface, groundNormal)
|
|
707
|
-
self.Character:PivotTo(targetCFrame)
|
|
708
|
-
task.wait()
|
|
709
|
-
local activeLerp = 0
|
|
710
|
-
task.spawn(function()
|
|
711
|
-
while true do
|
|
712
|
-
local dt = task.wait(1 / 60)
|
|
713
|
-
local lerpAlpha = activeLerp + (dt / self._standFadeTime)
|
|
714
|
-
local ended = false
|
|
715
|
-
if lerpAlpha >= 1 then
|
|
716
|
-
ended = true
|
|
717
|
-
lerpAlpha = 1
|
|
718
|
-
end
|
|
719
|
-
for partClone, realPart in cloneToRealMap do
|
|
720
|
-
partClone.CFrame = partClone.CFrame:Lerp(realPart.CFrame, lerpAlpha)
|
|
721
|
-
end
|
|
722
|
-
activeLerp = lerpAlpha
|
|
723
|
-
if ended then
|
|
724
|
-
for partClone, realPart in cloneToRealMap do
|
|
725
|
-
partClone:Destroy()
|
|
726
|
-
end
|
|
727
|
-
for thing, originalTransparency in originalTransparencies do
|
|
728
|
-
thing.Transparency = originalTransparency
|
|
729
|
-
end
|
|
730
|
-
return nil
|
|
731
|
-
end
|
|
732
|
-
end
|
|
733
|
-
end)
|
|
734
|
-
task.wait(self._standFadeTime)
|
|
735
|
-
end
|
|
611
|
+
local targetCFrame = CFrame.fromMatrix(centerPoint, forwardOnSurface, groundNormal)
|
|
612
|
+
if exitMode == Falldown.ExitMode.Immediate then
|
|
613
|
+
-- ── Immediate: snap character to standing pose, no clone or animation ──
|
|
614
|
+
self.Character:PivotTo(targetCFrame)
|
|
736
615
|
for _, descendant in self.Character:GetDescendants() do
|
|
737
616
|
if descendant:IsA("BasePart") then
|
|
738
617
|
descendant.Anchored = false
|
|
@@ -746,21 +625,174 @@ do
|
|
|
746
625
|
end
|
|
747
626
|
self.Humanoid.PlatformStand = false
|
|
748
627
|
self.HumanoidRootPart.Anchored = false
|
|
749
|
-
|
|
628
|
+
self.Humanoid.EvaluateStateMachine = true
|
|
629
|
+
self.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
|
|
630
|
+
self.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
|
|
631
|
+
self.Humanoid:ChangeState(Enum.HumanoidStateType.Running)
|
|
750
632
|
task.defer(function()
|
|
751
633
|
while self.Humanoid.MoveDirection.Magnitude <= 0 do
|
|
752
634
|
RunService.Stepped:Wait()
|
|
753
635
|
end
|
|
754
636
|
self.HumanoidRootPart:SetNetworkOwner(self.Owner)
|
|
755
637
|
end)
|
|
756
|
-
self.Humanoid.EvaluateStateMachine = true
|
|
757
|
-
self.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
|
|
758
|
-
self.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
|
|
759
|
-
self.Humanoid:ChangeState(Enum.HumanoidStateType.Running)
|
|
760
638
|
self.Ended:Fire()
|
|
761
639
|
self.Ended:Destroy()
|
|
762
|
-
|
|
763
|
-
|
|
640
|
+
else
|
|
641
|
+
-- ── Smooth: create fade clone, play getup animation, tween ──
|
|
642
|
+
local clonedCharacter = Instance.new("Model")
|
|
643
|
+
clonedCharacter.Name = "Falldown_FadeClone_Temp"
|
|
644
|
+
local humanoid = Instance.new("Humanoid")
|
|
645
|
+
local animator = humanoid:FindFirstChildOfClass("Animator")
|
|
646
|
+
humanoid.RigType = self.Humanoid.RigType
|
|
647
|
+
humanoid.RequiresNeck = false
|
|
648
|
+
humanoid.AutoRotate = false
|
|
649
|
+
if animator then
|
|
650
|
+
for _, anim in animator:GetPlayingAnimationTracks() do
|
|
651
|
+
anim:Stop()
|
|
652
|
+
end
|
|
653
|
+
animator:Destroy()
|
|
654
|
+
end
|
|
655
|
+
local cloneCG = HttpService:GenerateGUID(false)
|
|
656
|
+
PhysicsService:RegisterCollisionGroup(cloneCG)
|
|
657
|
+
PhysicsService:CollisionGroupSetCollidable(cloneCG, "Default", false)
|
|
658
|
+
PhysicsService:CollisionGroupSetCollidable(cloneCG, self._bodypartGroupId, false)
|
|
659
|
+
PhysicsService:CollisionGroupSetCollidable(cloneCG, cloneCG, false)
|
|
660
|
+
local cloneToRealMap = {}
|
|
661
|
+
local originalTransparencies = {}
|
|
662
|
+
for _, descendant in self.Character:GetDescendants() do
|
|
663
|
+
if descendant:IsA("BasePart") then
|
|
664
|
+
local partClone = descendant:Clone()
|
|
665
|
+
partClone.Anchored = true
|
|
666
|
+
partClone.CollisionGroup = cloneCG
|
|
667
|
+
partClone.CFrame = descendant.CFrame
|
|
668
|
+
cloneToRealMap[partClone] = descendant
|
|
669
|
+
local _transparency = descendant.Transparency
|
|
670
|
+
originalTransparencies[descendant] = _transparency
|
|
671
|
+
for _1, partDesc in partClone:GetDescendants() do
|
|
672
|
+
if partDesc:IsA("JointInstance") or partDesc:IsA("Constraint") or partDesc:IsA("Attachment") then
|
|
673
|
+
partDesc:Destroy()
|
|
674
|
+
elseif partDesc:IsA("Decal") then
|
|
675
|
+
local _arg0_2 = descendant:FindFirstChild(partDesc.Name)
|
|
676
|
+
local _transparency_1 = partDesc.Transparency
|
|
677
|
+
originalTransparencies[_arg0_2] = _transparency_1
|
|
678
|
+
end
|
|
679
|
+
end
|
|
680
|
+
partClone.Parent = clonedCharacter
|
|
681
|
+
elseif descendant:IsA("Clothing") then
|
|
682
|
+
local clothingClone = descendant:Clone()
|
|
683
|
+
clothingClone.Parent = clonedCharacter
|
|
684
|
+
end
|
|
685
|
+
end
|
|
686
|
+
humanoid.Parent = clonedCharacter
|
|
687
|
+
clonedCharacter.Parent = Workspace
|
|
688
|
+
for thing, originalTransparency in originalTransparencies do
|
|
689
|
+
thing.Transparency = 1
|
|
690
|
+
end
|
|
691
|
+
self.Humanoid.PlatformStand = false
|
|
692
|
+
self.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
|
|
693
|
+
self.HumanoidRootPart.Anchored = true
|
|
694
|
+
local facing = ActiveRagdoll:GetVerticalDirection(self.HumanoidRootPart.CFrame.LookVector)
|
|
695
|
+
local activeAnimation = nil
|
|
696
|
+
if facing == 0 then
|
|
697
|
+
activeAnimation = self.GetupBackAnimation
|
|
698
|
+
else
|
|
699
|
+
activeAnimation = self.GetupFrontAnimation
|
|
700
|
+
end
|
|
701
|
+
task.spawn(function()
|
|
702
|
+
if activeAnimation then
|
|
703
|
+
self.Character:PivotTo(targetCFrame)
|
|
704
|
+
activeAnimation:Play(0, 1, 0)
|
|
705
|
+
while not activeAnimation.IsPlaying do
|
|
706
|
+
task.wait()
|
|
707
|
+
end
|
|
708
|
+
activeAnimation.TimePosition = 0.0
|
|
709
|
+
task.wait()
|
|
710
|
+
local activeLerp = 0
|
|
711
|
+
task.spawn(function()
|
|
712
|
+
while true do
|
|
713
|
+
local dt = task.wait(1 / 60)
|
|
714
|
+
local lerpAlpha = activeLerp + (dt / math.min(self._standFadeTime, activeAnimation.Length))
|
|
715
|
+
local ended = false
|
|
716
|
+
if lerpAlpha >= 1 then
|
|
717
|
+
ended = true
|
|
718
|
+
lerpAlpha = 1
|
|
719
|
+
end
|
|
720
|
+
for partClone, realPart in cloneToRealMap do
|
|
721
|
+
partClone.CFrame = partClone.CFrame:Lerp(realPart.CFrame, lerpAlpha)
|
|
722
|
+
end
|
|
723
|
+
activeLerp = lerpAlpha
|
|
724
|
+
if ended then
|
|
725
|
+
for partClone, realPart in cloneToRealMap do
|
|
726
|
+
partClone:Destroy()
|
|
727
|
+
end
|
|
728
|
+
for thing, originalTransparency in originalTransparencies do
|
|
729
|
+
thing.Transparency = originalTransparency
|
|
730
|
+
end
|
|
731
|
+
return nil
|
|
732
|
+
end
|
|
733
|
+
end
|
|
734
|
+
end)
|
|
735
|
+
activeAnimation:AdjustSpeed(1)
|
|
736
|
+
activeAnimation.Ended:Wait()
|
|
737
|
+
else
|
|
738
|
+
self.Character:PivotTo(targetCFrame)
|
|
739
|
+
task.wait()
|
|
740
|
+
local activeLerp = 0
|
|
741
|
+
task.spawn(function()
|
|
742
|
+
while true do
|
|
743
|
+
local dt = task.wait(1 / 60)
|
|
744
|
+
local lerpAlpha = activeLerp + (dt / self._standFadeTime)
|
|
745
|
+
local ended = false
|
|
746
|
+
if lerpAlpha >= 1 then
|
|
747
|
+
ended = true
|
|
748
|
+
lerpAlpha = 1
|
|
749
|
+
end
|
|
750
|
+
for partClone, realPart in cloneToRealMap do
|
|
751
|
+
partClone.CFrame = partClone.CFrame:Lerp(realPart.CFrame, lerpAlpha)
|
|
752
|
+
end
|
|
753
|
+
activeLerp = lerpAlpha
|
|
754
|
+
if ended then
|
|
755
|
+
for partClone, realPart in cloneToRealMap do
|
|
756
|
+
partClone:Destroy()
|
|
757
|
+
end
|
|
758
|
+
for thing, originalTransparency in originalTransparencies do
|
|
759
|
+
thing.Transparency = originalTransparency
|
|
760
|
+
end
|
|
761
|
+
return nil
|
|
762
|
+
end
|
|
763
|
+
end
|
|
764
|
+
end)
|
|
765
|
+
task.wait(self._standFadeTime)
|
|
766
|
+
end
|
|
767
|
+
for _, descendant in self.Character:GetDescendants() do
|
|
768
|
+
if descendant:IsA("BasePart") then
|
|
769
|
+
descendant.Anchored = false
|
|
770
|
+
descendant.AssemblyLinearVelocity = Vector3.zero
|
|
771
|
+
descendant.AssemblyAngularVelocity = Vector3.zero
|
|
772
|
+
if descendant:GetAttribute("Falldown_Reverse_CC_To") ~= nil then
|
|
773
|
+
descendant.CanCollide = descendant:GetAttribute("Falldown_Reverse_CC_To")
|
|
774
|
+
descendant:SetAttribute("Falldown_Reverse_CC_To", nil)
|
|
775
|
+
end
|
|
776
|
+
end
|
|
777
|
+
end
|
|
778
|
+
self.Humanoid.PlatformStand = false
|
|
779
|
+
self.HumanoidRootPart.Anchored = false
|
|
780
|
+
RunService.Heartbeat:Wait()
|
|
781
|
+
task.defer(function()
|
|
782
|
+
while self.Humanoid.MoveDirection.Magnitude <= 0 do
|
|
783
|
+
RunService.Stepped:Wait()
|
|
784
|
+
end
|
|
785
|
+
self.HumanoidRootPart:SetNetworkOwner(self.Owner)
|
|
786
|
+
end)
|
|
787
|
+
self.Humanoid.EvaluateStateMachine = true
|
|
788
|
+
self.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
|
|
789
|
+
self.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
|
|
790
|
+
self.Humanoid:ChangeState(Enum.HumanoidStateType.Running)
|
|
791
|
+
self.Ended:Fire()
|
|
792
|
+
self.Ended:Destroy()
|
|
793
|
+
clonedCharacter:Destroy()
|
|
794
|
+
end)
|
|
795
|
+
end
|
|
764
796
|
PhysicsService:UnregisterCollisionGroup(self._proxyGroupId)
|
|
765
797
|
PhysicsService:UnregisterCollisionGroup(self._bodypartGroupId)
|
|
766
798
|
self.Destroyed:Fire()
|
|
@@ -826,7 +858,7 @@ do
|
|
|
826
858
|
end
|
|
827
859
|
return proxyMap
|
|
828
860
|
end
|
|
829
|
-
function Falldown:CreateActiveRagdollR6(character, humanoid, standFadeTime, automaticDuration, getupFront, getupBack)
|
|
861
|
+
function Falldown:CreateActiveRagdollR6(character, humanoid, standFadeTime, automaticDuration, exitMode, getupFront, getupBack)
|
|
830
862
|
local leftArm = character:FindFirstChild("Left Arm")
|
|
831
863
|
local rightArm = character:FindFirstChild("Right Arm")
|
|
832
864
|
local leftLeg = character:FindFirstChild("Left Leg")
|
|
@@ -1064,9 +1096,9 @@ do
|
|
|
1064
1096
|
end
|
|
1065
1097
|
end
|
|
1066
1098
|
humanoid.EvaluateStateMachine = false
|
|
1067
|
-
return ActiveRagdoll.new(character, height, standFadeTime, humanoid, humanoidRootPart, leftLeg, rightLeg, destructionInfo, proxyGroupId, bodypartGroupId, ProxyMapping, automaticDuration, getupFrontTrack, getupBackTrack)
|
|
1099
|
+
return ActiveRagdoll.new(character, height, standFadeTime, humanoid, humanoidRootPart, leftLeg, rightLeg, destructionInfo, proxyGroupId, bodypartGroupId, ProxyMapping, automaticDuration, exitMode, getupFrontTrack, getupBackTrack)
|
|
1068
1100
|
end
|
|
1069
|
-
function Falldown:CreateActiveRagdollR15(character, humanoid, standFadeTime, automaticDuration, getupFront, getupBack)
|
|
1101
|
+
function Falldown:CreateActiveRagdollR15(character, humanoid, standFadeTime, automaticDuration, exitMode, getupFront, getupBack)
|
|
1070
1102
|
local leftUpperArm = character:FindFirstChild("LeftUpperArm")
|
|
1071
1103
|
local leftLowerArm = character:FindFirstChild("LeftLowerArm")
|
|
1072
1104
|
local leftHand = character:FindFirstChild("LeftHand")
|
|
@@ -1518,9 +1550,9 @@ do
|
|
|
1518
1550
|
end
|
|
1519
1551
|
end
|
|
1520
1552
|
humanoid.EvaluateStateMachine = false
|
|
1521
|
-
return ActiveRagdoll.new(character, height, standFadeTime, humanoid, humanoidRootPart, leftFoot, rightFoot, destructionInfo, proxyGroupId, bodypartGroupId, ProxyMapping, automaticDuration, getupFrontTrack, getupBackTrack)
|
|
1553
|
+
return ActiveRagdoll.new(character, height, standFadeTime, humanoid, humanoidRootPart, leftFoot, rightFoot, destructionInfo, proxyGroupId, bodypartGroupId, ProxyMapping, automaticDuration, exitMode, getupFrontTrack, getupBackTrack)
|
|
1522
1554
|
end
|
|
1523
|
-
function Falldown:RagdollCharacter(character, standupFadeTime, automaticDuration, getupFront, getupBack)
|
|
1555
|
+
function Falldown:RagdollCharacter(character, standupFadeTime, automaticDuration, exitMode, getupFront, getupBack)
|
|
1524
1556
|
local __activeRagdolls = self._activeRagdolls
|
|
1525
1557
|
local _character = character
|
|
1526
1558
|
if __activeRagdolls[_character] ~= nil then
|
|
@@ -1531,7 +1563,7 @@ do
|
|
|
1531
1563
|
return nil
|
|
1532
1564
|
end
|
|
1533
1565
|
if humanoid.RigType == Enum.HumanoidRigType.R6 then
|
|
1534
|
-
local createdActiveRagdoll = self:CreateActiveRagdollR6(character, humanoid, standupFadeTime, automaticDuration, getupFront, getupBack)
|
|
1566
|
+
local createdActiveRagdoll = self:CreateActiveRagdollR6(character, humanoid, standupFadeTime, automaticDuration, exitMode, getupFront, getupBack)
|
|
1535
1567
|
if createdActiveRagdoll then
|
|
1536
1568
|
local __activeRagdolls_1 = self._activeRagdolls
|
|
1537
1569
|
local _character_1 = character
|
|
@@ -1550,7 +1582,7 @@ do
|
|
|
1550
1582
|
return nil
|
|
1551
1583
|
end
|
|
1552
1584
|
else
|
|
1553
|
-
local createdActiveRagdoll = self:CreateActiveRagdollR15(character, humanoid, standupFadeTime, automaticDuration, getupFront, getupBack)
|
|
1585
|
+
local createdActiveRagdoll = self:CreateActiveRagdollR15(character, humanoid, standupFadeTime, automaticDuration, exitMode, getupFront, getupBack)
|
|
1554
1586
|
if createdActiveRagdoll then
|
|
1555
1587
|
local __activeRagdolls_1 = self._activeRagdolls
|
|
1556
1588
|
local _character_1 = character
|
|
@@ -1570,7 +1602,7 @@ do
|
|
|
1570
1602
|
end
|
|
1571
1603
|
end
|
|
1572
1604
|
end
|
|
1573
|
-
function Falldown:UnragdollCharacter(character, delayTime)
|
|
1605
|
+
function Falldown:UnragdollCharacter(character, delayTime, exitMode)
|
|
1574
1606
|
local __activeRagdolls = self._activeRagdolls
|
|
1575
1607
|
local _character = character
|
|
1576
1608
|
local activeRagdoll = __activeRagdolls[_character]
|
|
@@ -1583,7 +1615,11 @@ do
|
|
|
1583
1615
|
local __activeRagdolls_2 = self._activeRagdolls
|
|
1584
1616
|
local _character_2 = character
|
|
1585
1617
|
__activeRagdolls_2[_character_2] = nil
|
|
1586
|
-
|
|
1618
|
+
local _condition = exitMode
|
|
1619
|
+
if not (_condition ~= 0 and _condition == _condition and _condition) then
|
|
1620
|
+
_condition = Falldown.ExitMode.Smooth
|
|
1621
|
+
end
|
|
1622
|
+
activeRagdoll:Destroy(_condition)
|
|
1587
1623
|
end
|
|
1588
1624
|
end)
|
|
1589
1625
|
else
|
|
@@ -1593,18 +1629,31 @@ do
|
|
|
1593
1629
|
local __activeRagdolls_2 = self._activeRagdolls
|
|
1594
1630
|
local _character_2 = character
|
|
1595
1631
|
__activeRagdolls_2[_character_2] = nil
|
|
1596
|
-
|
|
1632
|
+
local _condition = exitMode
|
|
1633
|
+
if not (_condition ~= 0 and _condition == _condition and _condition) then
|
|
1634
|
+
_condition = Falldown.ExitMode.Smooth
|
|
1635
|
+
end
|
|
1636
|
+
activeRagdoll:Destroy(_condition)
|
|
1597
1637
|
end
|
|
1598
1638
|
end
|
|
1599
1639
|
end
|
|
1600
1640
|
end
|
|
1601
|
-
function Falldown:
|
|
1641
|
+
function Falldown:IsCharacterRagdolled(character)
|
|
1642
|
+
local __activeRagdolls = self._activeRagdolls
|
|
1643
|
+
local _character = character
|
|
1644
|
+
return __activeRagdolls[_character] ~= nil
|
|
1645
|
+
end
|
|
1646
|
+
function Falldown:UnragdollAllCharacters(delayTime, exitMode)
|
|
1602
1647
|
if delayTime ~= 0 and delayTime == delayTime and delayTime then
|
|
1603
1648
|
delay(delayTime, function()
|
|
1604
1649
|
for character, activeRagdoll in self._activeRagdolls do
|
|
1605
1650
|
if self._activeRagdolls[character] ~= nil then
|
|
1606
1651
|
self._activeRagdolls[character] = nil
|
|
1607
|
-
|
|
1652
|
+
local _condition = exitMode
|
|
1653
|
+
if not (_condition ~= 0 and _condition == _condition and _condition) then
|
|
1654
|
+
_condition = Falldown.ExitMode.Smooth
|
|
1655
|
+
end
|
|
1656
|
+
activeRagdoll:Destroy(_condition)
|
|
1608
1657
|
end
|
|
1609
1658
|
end
|
|
1610
1659
|
end)
|
|
@@ -1612,7 +1661,11 @@ do
|
|
|
1612
1661
|
for character, activeRagdoll in self._activeRagdolls do
|
|
1613
1662
|
if self._activeRagdolls[character] ~= nil then
|
|
1614
1663
|
self._activeRagdolls[character] = nil
|
|
1615
|
-
|
|
1664
|
+
local _condition = exitMode
|
|
1665
|
+
if not (_condition ~= 0 and _condition == _condition and _condition) then
|
|
1666
|
+
_condition = Falldown.ExitMode.Smooth
|
|
1667
|
+
end
|
|
1668
|
+
activeRagdoll:Destroy(_condition)
|
|
1616
1669
|
end
|
|
1617
1670
|
end
|
|
1618
1671
|
end
|
|
@@ -1623,6 +1676,10 @@ do
|
|
|
1623
1676
|
SplitEqual = 2,
|
|
1624
1677
|
RandomMax = 3,
|
|
1625
1678
|
}
|
|
1679
|
+
Falldown.ExitMode = {
|
|
1680
|
+
Smooth = 0,
|
|
1681
|
+
Immediate = 1,
|
|
1682
|
+
}
|
|
1626
1683
|
Falldown._activeRagdolls = {}
|
|
1627
1684
|
end
|
|
1628
1685
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/falldown",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A realistic ragdoll physics system for Roblox with smooth getup animations, collision management, and customizable velocity modes. Supports both R6 and R15 rigs with surface-aware positioning.",
|
|
5
5
|
"main": "out/init.luau",
|
|
6
6
|
"scripts": {
|