fivem icon indicating copy to clipboard operation
fivem copied to clipboard

Event to make a ragdolled ped get up again (unragdoll)

Open mcNuggets1 opened this issue 2 years ago • 17 comments

There currently does not seem to be any functionality to either ragdoll someone properly without them getting up again automatically after some time (SetPedToRagdoll) or get up from being ragdolled at all!

There is just one variable for time in SetPedToRagdoll THAT can't be reset, even though I was thinking, ResetPedRagdollTimer would do that. SetPedToRagdoll also twitches the ragdoll, every time, it is applied again.

Calling ClearPedTasks does nothing on a ragdolled player, ClearPedTasksImmediately t-poses the player for a bit and the returns to the base idle animation. (No get up animation whatsoever here)

I would suggest exposing more natives regarding ragdolling or giving some type of way to unragdoll a player atleast.

mcNuggets1 avatar Nov 28 '23 21:11 mcNuggets1

Sounds like a feature request not a issue ¯_(ツ)_/¯

Yum1x avatar Dec 05 '23 20:12 Yum1x

I believe you can use RESET_PED_RAGDOLL_TIMER to make ped get out of ragdoll state earlier.

Disquse avatar Dec 06 '23 13:12 Disquse

I believe you can use RESET_PED_RAGDOLL_TIMER to make ped get out of ragdoll state earlier.

That does not work.

mcNuggets1 avatar Jan 16 '24 13:01 mcNuggets1

I think clever use of RESET_PED_RAGDOLL_TIMER can still achieve what you are trying to capture: A way to ragdoll indefinitely, or until some condition is met (e.g., no longer knocked out), that allows a proper exiting of the CTaskNMRelax (iirc) task. Hand-waving a bit:

SetPedToRagdoll(PlayerPedId(), 100, 200, 0, false, false, false)
while SomeCondition do
   Wait(0)
   ResetPedRagdollTimer(PlayerPedId())
end

gottfriedleibniz avatar Feb 02 '24 23:02 gottfriedleibniz

ResetPedRagdollTimer does not do anything. It does not stop the last ragdoll timer, the player still gets up after the time configured in SetPedToRagdoll in my tests.

mcNuggets1 avatar Feb 14 '24 12:02 mcNuggets1

Can you provide an example as to how you are running/testing this?

gottfriedleibniz avatar Feb 14 '24 18:02 gottfriedleibniz

SetPedToRagdoll(ped, 1000, 1000, 0, false, false, false) in a 0 wait loop, as otherwise it just does not work. Any value above 10~ seconds also seems to be ignored. After the loop has ended, I call ResetPedRagdollTimer.

I also found out, that SetPedToRagdoll has instances, in which other players do see the player as standing.

mcNuggets1 avatar Feb 28 '24 12:02 mcNuggets1

Using

local timeToRagdoll = 10000
local ped = PlayerPedId()
local ragdoll = true
SetPedToRagdoll(ped, 10, 10, 0, false, false, false)
CreateThread(function()
    while ragdoll do
        Wait(0)
        ResetPedRagdollTimer(ped)
    end
end)
Wait(timeToRagdoll)
ragdoll = false

works perfectly fine for me and achieves exactly what you're asking for.

ResetPedRagdollTimer does not reset the end time of the ragdoll task, but rather resets the start time, making this an infinite task when repeatedly called. (This is also intended to be called every frame)

tens0rfl0w avatar Feb 28 '24 21:02 tens0rfl0w

Ah I totally misunerstood the function, it now makes much more sense. Thanks for clarifying that!

mcNuggets1 avatar Feb 28 '24 21:02 mcNuggets1

I tried using it. It did work for the local player, but for other players the ragdoll is twitching, trying to get up, etc.

mcNuggets1 avatar Mar 03 '24 12:03 mcNuggets1

https://github.com/citizenfx/fivem/assets/18447482/0b9124f8-003d-460b-ae16-1def56831716

It shows this to other players.

mcNuggets1 avatar Mar 03 '24 12:03 mcNuggets1

Works perfectly fine for me. However, if you're trying to reset the ragdoll timer on a remotely owned ped this won't work for obv reasons. This only works on the local player ped or peds the client has network ownership of (working around this limitation in code should be easy though, e.g. network events/state bags/...).

https://github.com/citizenfx/fivem/assets/57523343/6d466a34-4bc3-4477-8375-6f33c4e07920

tens0rfl0w avatar Mar 04 '24 11:03 tens0rfl0w

As soon as you hit the ped, it begins twitching and trying to get up, if you dont run EnableBoundAnkles (or whatever). Even when activated, the player still twitches for others and sometimes for themselves. Calling SetPedToRagdoll every frame sort of fixes that, but introduces new issues such as desyincing. I would make a video, but I dont have any software for it, currently.

mcNuggets1 avatar Mar 25 '24 10:03 mcNuggets1

Also the networking is completely broken for ragdolls. It shows a completely false position sometimes.

mcNuggets1 avatar Mar 26 '24 10:03 mcNuggets1

That isn't a bug, physics for peds are completely client sided so where they rag-doll will be different for every client.

AvarianKnight avatar Mar 26 '24 10:03 AvarianKnight

That isn't a bug, physics for peds are completely client sided so where they rag-doll will be different for every client.

The position of the ped is still corrected for a certain period of time. It just stops after some time.

mcNuggets1 avatar Apr 04 '24 16:04 mcNuggets1

NetworkCreateSynchronisedScene needs the player to be not ragdolled to be executed properly. Here we have a usage for an Unragdoll native now. ClearPedTasksImmediately takes up to 100ms to properly do it.

mcNuggets1 avatar Jul 01 '24 13:07 mcNuggets1