I’m trying to set up an animation that has an entry to make it look less, sudden. I’m waiting until the entry animation is at 0.95 with GetEntityAnimCurrentTime, but it’s still very noticeable. I’ve also tried setting the current animation time of the second animation but that did nothing.
My code:
while not HasAnimDictLoaded( "busted" ) do
RequestAnimDict( "busted" )
Citizen.Wait( 5 )
end
TaskPlayAnim( ped, "busted", "idle_2_hands_up", 8.0, -8, -1, 49, 0, 0, 0, 0 )
while ( GetEntityAnimCurrentTime( ped, "busted", "idle_2_hands_up" ) < 0.95 ) do
Citizen.Wait( 0 )
end
TaskPlayAnim( ped, "busted", "idle_a", 8.0, -8, -1, 49, 0, 0, 0, 0 )
Below is a gif of the issue that I have:
So you want the Animation to stop when the hand are behind the head?
Does the Animation stop when the hands are behind the head or is something else happening?
I’m trying to make it so when the hands are behind the player’s head, it then plays the idle animation from the same dict. If you watch the gif you’ll notice a point where the player’s arms teleport down by their sides then back behind their head, that is where the first animation ends and the second one starts, I’m trying to smooth that out.
Ok, but why aren’t you just freezing the animation at the last frame (hands behind the head)?
Because then the player would be frozen like a statue, the idle anim has some movement. Then I can also use the exit animation when they put their hands down again.
I managed to get it to work.
What did you end up doing? curious
I messed around with the flags and made it so the first animation was set to flag 2 (ANIM_FLAG_STOP_LAST_FRAME ), I then waited until the animation had finished using GetEntityAnimCurrentTime, cleared the ped tasks then played the idle animation with flags 49 (ANIM_FLAG_ENABLE_PLAYER_CONTROL + ANIM_FLAG_UPPERBODY + ANIM_FLAG_REPEAT).
Ah heck just have the code 
--[[------------------------------------------------------------------------
Hands Up w/knees and other Animation Commands
------------------------------------------------------------------------]]--
function loadAnimDict( dict )
while ( not HasAnimDictLoaded( dict ) ) do
RequestAnimDict( dict )
Citizen.Wait( 5 )
end
end
RegisterNetEvent( 'wk:handsUp' )
AddEventHandler( 'wk:handsUp', function()
local ped = GetPlayerPed( -1 )
if ( DoesEntityExist( ped ) and not IsEntityDead( ped ) ) then
loadAnimDict( "ped" )
if ( IsEntityPlayingAnim( ped, "ped", "handsup_base", 3 ) ) then
ClearPedSecondaryTask( ped )
else
TaskPlayAnim( ped, "ped", "handsup_enter", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
while ( GetEntityAnimCurrentTime( ped, "ped", "handsup_enter" ) < 0.999999 ) do
Citizen.Wait( 0 )
end
ClearPedTasks( ped )
TaskPlayAnim( ped, "ped", "handsup_base", 8.0, 1.0, -1, 49, 0, 0, 0, 0 )
end
end
end )
4 Likes