Creating a dynamic reload animation

For certain guns that require loading a single round at a time (i.e. sniper rifles), what would be the most efficient way of correctly animating the player loading the amount of rounds necessary?

Example:
I have a Gewehr 98 (bolt-action rifle | 5 round capacity) and I fire 3 rounds. When I trigger the reload function, my player only loads 3 new rounds into the rifle.

Likewise, when I fire 2 rounds, my player only loads 2 new rounds.

I’ve tried doing a loop combined with the KeyframeReached event but it’s not efficient and the animations often glitch.

4 Likes

I usually don’t make my animations using the animation editor which makes it easier for me to just change animation states, however, what you can do is probably mark the end of a counted reload animation and switch into it, or make the animation blend from intro to loop to end using AdjustWeight and AdjustSpeed or just play and stop

1 Like

Here is a very simple example, looks goofy as all hell but it works.

local playUntilDone = function(anim)
	anim:Play()
	anim.Stopped:Wait()
end

local ammoCount = 5
playUntilDone(anims.intro)
for i = 1, ammoCount do
	playUntilDone(anims.loop)
end
playUntilDone(anims.ending)

https://i.gyazo.com/496f8f07eafce0173390f74cedb49ee7.mp4

I honestly have no idea what is wrong with his leg

You can do the same if you actually loop the reload animation but you would need to check whenever it loops instead of whenever it stops.

1 Like

Do you have any idea of how I could stop animation delay? Sometimes when reloading, the “intro” animation (which in my case is the player opening the rifle’s bolt) plays correctly and stops, but there’s a small delay and then the ‘loop’ animations play.

Forgot to mention, when the delay happens, the player returns to the ‘idle’ (holding the rifle) animation.

Another way you can go about this is instead of uploading multiple animations (bringing gun up, inserting gun, back to idle) , just have one animation and use the TimePosition of the animation to replay the bullet insert.

Try placing animation events right before the ending and just superimpose it.

1 Like

This ended up being my solution. What I do is I stop the animation 0.1 seconds before I need to play the next one.