How to play animation montage from the animation blueprint

Hello,
I’m currently trying to add a reload feature to the shooter project and I’m having trouble finding out how to play the animation montage that I created in my animation blueprint. I have a bool that checks to see if the character is reloading, but I cant figure out how to check with it’s true or not. I’m also not sure if I’m suppose to call the C++ function that I have for reloading the weapon.

Not entirely sure how you’ve set up reloading but in theory it could be something like this

void ShooterCharacter::Reload()
{
    //do reload stuff
    PlayAnimMontage(ReloadAnim);
}

Where ReloadAnim is a UAnimMontage* exposed as a UPROPERTY and set in the editor.

I’ll just that a try and post the results.

Okay, so here is my reload function that includes the call to the PlayAnimMontage.

void AShooterCharacter::ReloadWeapon()
{
	if (Gun && ReloadMontage)
	{
		if (Gun->CurrentAmmo != Gun->MaxClipAmmo)
		{
			if (Gun->MaxAmmo - (Gun->MaxClipAmmo - Gun->CurrentAmmo) >= 0)
			{
				PlayAnimMontage(ReloadMontage);
				Gun->MaxAmmo -= (Gun->MaxClipAmmo - Gun->CurrentAmmo);
				Gun->CurrentAmmo = Gun->MaxClipAmmo;
			}
			else
			{
				Gun->CurrentAmmo += Gun->MaxAmmo;
				Gun->MaxAmmo = 0;
			}
		}
	}
}

While it works there is a slight bug in that when I reload, the gun goes off into space. I took a look at the montage it self and I see why and that because of the weapon_r bone but I’m not sure how to fix that. I can provide a short clip if needed

A clip would be helpful.

Sorry for the late response. I was unable to unload a video because of the format but I was able to get a screen capture.


As you can see when the character reloads the gun, the gun goes off into space.

And the montage looks fine in the preview?

Originally the montage is a little off. But, after adjusting it, it looks fine but that doesn’t carry on into the gameplay where the reload animation is still off here are two images of the montage.


The first is the original and the second is the edited version where I moved the weapon bone into a more appropriate position. I think the issue is with the weapon_r bone. In the lectures for this project we hide the bone.

Privacy & Terms