boss0782
(boss0782)
August 5, 2019, 9:26am
1
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.
Firefly74
(Firefly74)
August 5, 2019, 10:09am
2
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 )
boss0782
(boss0782)
August 5, 2019, 1:21pm
3
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()?
boss0782
(boss0782)
August 7, 2019, 2:08pm
4
If you mean editor breakpoints, i got broken breakpoints there.
boss0782
(boss0782)
August 7, 2019, 2:09pm
5
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
Firefly74
(Firefly74)
August 7, 2019, 2:49pm
6
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
boss0782
(boss0782)
August 8, 2019, 3:13pm
7
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):
boss0782
(boss0782)
August 9, 2019, 8:20pm
8
I’ll better try to do all this in blueprints. Anyway, thanks for you help and sorry for my english