Volltron Posted September 23, 2022 Share Posted September 23, 2022 Hi, I was trying to make a script that spawns a ped underground and makes it crawl its way up, but the issue is that whenever the animation changes, it's not smooth, you can see the character glitching for a few frames. Code below: function spawnS(playerSource, commandName) local x, y, z = getElementPosition(playerSource) local sPed = createPed(19, x, y, z-2) setElementCollisionsEnabled(sPed, false) setTimer(function() setPedAnimation(sPed, "ped", "climb_pull",-1, false,true,false,false, 0, false) setTimer(setPedAnimationSpeed, 100, 1, sPed, "climb_pull", 0.4) setTimer(function() setElementPosition(sPed, x, y, z-1, true) setPedAnimation( sPed, "ped", "climb_stand", -1, false,false,false,false, 0, false) setTimer(function() setPedAnimationSpeed(sPed, "climb_stand", 0.5) setTimer(function() setElementCollisionsEnabled(sPed, true) setElementPosition(sPed, x, y, z, true) setPedAnimation( sPed, "ped", "climb_stand_finish", -1, false,true,false,false) end, 1400, 1) end, 100, 1) end, 2000, 1) end, 100, 1) end addCommandHandler("s", spawnS) Is there any way of achieving this ? Link to comment
Shady1 Posted September 23, 2022 Share Posted September 23, 2022 (edited) 6 minutes ago, Volltron said: Hi, I was trying to make a script that spawns a ped underground and makes it crawl its way up, but the issue is that whenever the animation changes, it's not smooth, you can see the character glitching for a few frames. Code below: function spawnS(playerSource, commandName) local x, y, z = getElementPosition(playerSource) local sPed = createPed(19, x, y, z-2) setElementCollisionsEnabled(sPed, false) setTimer(function() setPedAnimation(sPed, "ped", "climb_pull",-1, false,true,false,false, 0, false) setTimer(setPedAnimationSpeed, 100, 1, sPed, "climb_pull", 0.4) setTimer(function() setElementPosition(sPed, x, y, z-1, true) setPedAnimation( sPed, "ped", "climb_stand", -1, false,false,false,false, 0, false) setTimer(function() setPedAnimationSpeed(sPed, "climb_stand", 0.5) setTimer(function() setElementCollisionsEnabled(sPed, true) setElementPosition(sPed, x, y, z, true) setPedAnimation( sPed, "ped", "climb_stand_finish", -1, false,true,false,false) end, 1400, 1) end, 100, 1) end, 2000, 1) end, 100, 1) end addCommandHandler("s", spawnS) Is there any way of achieving this ? hello @Volltron welcome to the forum, using nested timer may cause some problems, so I did not understand the system much, if you can be more descriptive we will help you Edited September 23, 2022 by Shady1 Link to comment
Volltron Posted September 24, 2022 Author Share Posted September 24, 2022 I'm trying to make the ped crawl from underground when it spawns, I'm using the timers to be able to change the animation and the animation speed since the climbing one is split. And I use setElementPosition to move the ped up so the next part of the climbing animation doesn't start in the same place as the first one. I'll try any recommendations, but I couldn't figure any other way of moving the ped up from under the ground while setting the climbing animation Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now