Animation

 Unreal

void UMy_AnimInstance::NativeInitializeAnimation() {

  if (theActorPawn == nullptr) theActorPawn = TryGetPawnOwner();//UPROPERTY() APawn* theActorPawn;

if (IsValid(theActorPawn)) thePawnMomnt_Framwork = theActorPawn->GetMovementComponent(); 

}

void UMy_AnimInstance::NativeUpdateAnimation(float DeltaSecond) {

if (thePawnMomnt_Framwork && theActorPawn) {//UPROPERTY() UPawnMovementComponent* thePawnMomnt_Framwork;

plyrMovmntSpeed = theActorPawn->GetVelocity().Size();UPROPERTY(BlueprintReadOnly) float plyrMovmntSpeed;

                                plyrIsJump = thePawnMomnt_Framwork->IsFalling();////UPROPERTY(BlueprintReadOnly) bool plyrIsJump;

                //UPROPERTY() AMyPlayerChar* thePlyrClass;

if ((thePlyrClass = Cast<AMyPlayerChar>(theActorPawn)) != nullptr)  plyrCrouch = thePlyrClass->isCrouch;//UPROPERTY(BlueprintReadOnly) bool plyrCrouch;

}

Unity

    Animator anim;

    void Start() => anim = GetComponentInChildren<Animator>();

    void Updtae() {

           var movX = Input.GetAxis("Horizontal") * plyrSped, movZ = Input.GetAxis("Vertical") * plyrSped;

           if (plyrSped >= 6) anim.SetFloat("Run", plyrSped);

           else if (plyrSped <= -6) anim.SetFloat("Run", -plyrSped);

           else anim.SetInteger("MoveX", movX);//if movX = -1 left Or 1 Right Or 0 mesns idle

           anim.SetBool("PlayerJump", plyrIsJmp);

           if (movX == 0 && plyrDie) anim.SetTrigger("PlayerDie");

    }

Comments

Popular posts from this blog

Open Level

Play Sound