Hello guys! My weapon mesh is attached to empty scene component of player. Weapon also have it’s own animations. When I trying to play weapon animation by calling function PlaySlash() from my player BP, animation just not working. How can i fix it?
Function PlaySlash from my weapon code:
void APickUpWeapon::PlaySlash()
{
WeaponMesh->PlayAnimation(Anim, false);
}
Weapon Mesh is USkeletalMeshComponent
Here is my player BP:
I will be very grateful for any help with it.
I would start with basic questions :
Are you sure the code is called ? ( log / breakpoint ? )
Are you sure “Anim” variable has a correct value ? ( set up and match the skeleton )
once all that is sure, after calling the code, while in PIE select the weapon mesh in world and check animation and animation mode there ( it should be correct, else post what you see )
I’m sure that code is called and looks like Anim variable has correct value
How can i select the weapon mesh in editor, while editor is frozen(after hitting breakpoint in PlaySlash()?
If you mean editor breakpoints, i got broken breakpoints there.
Finally, I have fixed all problems with editor breakpoints. Here is screenshot of what is
going on with weapon mesh after hitting breakpoint on PlaySlash() in player’s BP
from what i see you have some code that force “animation mode” to “UseAnimationBlueprint”
is you use animation blueprint for your unit, consider using animation montage and use " YourMesh->AnimScriptInstance->Montage_Play" function
I tried to do this, but looks like my UAnimMontage is NULL.
Here code from constructor:
static ConstructorHelpers::FObjectFinder<UAnimMontage>SlashMontageObj(TEXT("AnimMontage'/Game/Art/Katana/katana_SlashMontage.katana_SlashMontage'"));
UAnimMontage* slashAnimMontage = SlashMontageObj.Object;
And here is my function:
void APickUpWeapon::PlaySlash()
{
WeaponMesh->AnimScriptInstance->Montage_Play(slashAnimMontage);
}
Here is screenshot from my debug session(value of slashAnimMontage after completing the constructor):
I’ll better try to do all this in blueprints. Anyway, thanks for you help and sorry for my english 