Hello everyone, I know C++ very good, i know define classes,Structs,variables,loops,arrays and Etc… and how to use it of course. But i never developed games with unreal engine cpp so idk what the unreal engine commands do.
I did Download Mixamo Animation, and the character, and my question is How to Call the animation on the character Everytime i press a Specific button? for example i downloaded “punch” animation and i want that whenever i press left click on the mouse, My character will start the Punch animation.
Hello!
I am new to UE4 as well so bare with me if im not super in depth. But the way i did this was I created an animation instance class and set that as the animation instance on my USkeletalMeshComponent. My custom animation instance class was super simple and looked something like:
#include "CoreMinimal.h"
#include "Animation/AnimInstance.h"
#include "UCustomAnimInstance .generated.h"
/**
*
*/
UCLASS(transient, Blueprintable, hideCategories = AnimInstance, BlueprintType)
class APP UCustomAnimInstance : public UAnimInstance
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int MyCustomProp = 0;
};
The cpp file is a single line which is
#include "CustomAnimInstance.h"
Then inside my Actor class for the object i did:
USkeletalMeshComponent * myMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("NameOfYourMesh"));
this->animInstance = Cast<UCustomAnimInstance>(myMesh->GetAnimInstance());
Then you can use blueprints to handle the animations when you change the UCustomAnimInstance MyCustomProp variable.
For a more in depth tutorial take a look at: this
Hope this helps!
Tyler
Thank you Very much!