I’m seeking help today with switching between two reload animations for an equipped firearm depending on the situation—to elaborate, I’m taking a realistic approach to my firearm system; reloading when a given firearm is completely empty will play a “FullReload” animation, which is inserting a magazine and then subsequently chambering a new round into the empty chamber. Otherwise, reloading when a firearm has one or more rounds left will play a “BaseReload” animation, which is a quicker action that only requires inserting a new magazine.
My trouble is switching between the two at will. Attempting to keep my script optimized and to a minimal length, setting up a plethora of markers and events for the two animations separately was repetitive and not an option in my tastes, and I had thought simply doing the following would work better:
Note that this is just a simplified function snippet to provide elaboration
local reloadAnimation = Animator:LoadAnimation(Animations.Reload) --default reload for startup, is just a BaseReload if firearm.Stats.MagazineAmmo.Value == 0 then reloadAnimation = Animator:LoadAnimation(Animations.FullReload) else reloadAnimation = Animator:LoadAnimation(Animations.BaseReload) end reloadAnimation:Play()
Unfortunately, all of the marker-reached events tied to the
reloadAnimation variable become unresponsive once the variable is changed, as it is still stuck listening to the first
LoadAnimation it is attributed to.
I had found an initial solution by putting all these events under a function and having them all updated by calling that function whenever necessary. However, it gets pretty undesirable when I’m left having to update the reload animations’ important events such as
I guess I could commit to the method I found and go about also updating these events through another “parent” function, but I thought I’d seek out some help on the forums before I go through with it.
So, are there perhaps any other more effective methods? Thanks as always.