admin管理员组文章数量:1245083
I have made a unreal engine 5.1 project, in which I used this tutorial to set up character movement and animation. I am using this asset as the player. My problem is that the movement animations (i.e. running and walking) are blending with the attack animation across the entire rig. This causes the animations to appear broken, especially when the attack and running animations are playing simultaneously.
I have included a video demonstrating the problem here via mediafire. If there is a better way to convey an mp4 file on stack overflow, please let me know in the comments. The video showcases the animation working relatively well when the player is idle or walking, and looking completely fucked when the player is running. If there is a way to disable the blending on the upper-body of the character, I believe the animation would not look so munted. Here is my code for playing the animation below for reference. Any help is appreciated.
header:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Misc/OutputDevice.h"
#include "Misc/OutputDeviceNull.h"
#include "UsefulDefs.h"
#include "Animation/AnimSequence.h"
#include "KiritoCharacter.generated.h"
UCLASS()
class IHATEUNREALENGINE_API AKiritoCharacter : public ACharacter
{
GENERATED_BODY()
public:
AKiritoCharacter();
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
virtual void Tick(float DeltaTime) override;
protected:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
class USpringArmComponent* SpringArmComp;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
class UCameraComponent* CameraComp;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Anims")
class UAnimMontage *attackMontage;
class UAnimSequence *attackAnimation;
void BeginSprint();
void EndSprint();
void BeginCrouch();
void EndCrouch();
void SwingSword();
void MoveForward(float InputAxis);
void MoveRight(float InputAxis);
virtual void BeginPlay() override;
private:
};
source:
#include "KiritoCharacter.h"
#include "GameFramework/SpringArmComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "Camera/CameraComponent.h"
#define MoveDir(axis)\
if (!axisValue) return;\
const FRotator rotator(.0, Controller->GetControlRotation().Yaw, .0);\
AddMovementInput(FRotationMatrix(rotator).GetUnitAxis(EAxis::axis), axisValue)
constexpr float sensitivity = .3f;
constexpr float runSpeed = 1000.f, walkSpeed = 600.f;
DECLARE_LOG_CATEGORY_EXTERN(GameLog, Log, All);
DEFINE_LOG_CATEGORY(GameLog);
AKiritoCharacter::AKiritoCharacter()
{
static ConstructorHelpers::FObjectFinder<UAnimSequence> anim(TEXT("/Game/ParagonKwang/Characters/Heroes/Kwang/Animations/PrimaryAttack_A_Slow"));
attackAnimation = anim.Object;
SpringArmComp = CreateDefaultSubobject<USpringArmComponent>(TEXT("spring arm component"));
CameraComp = CreateDefaultSubobject<UCameraComponent>(TEXT("camera component"));
GetMesh()->SetRelativeLocationAndRotation(FVector(.0f, .0f, -90.0f), FQuat(FRotator(.0f, /*-90*/.0f, .0f)));
SpringArmComp->SetupAttachment(GetMesh());
CameraComp->SetupAttachment(SpringArmComp, USpringArmComponent::SocketName);
SpringArmComp->bUsePawnControlRotation = true;
SpringArmComp->TargetArmLength = 260.0f;
SpringArmComp->SocketOffset = FVector(.0, -50.0, 150.0);
SpringArmComp->bDoCollisionTest = false;
auto charMoveComp = GetCharacterMovement();
charMoveComp->RotationRate = FRotator(sensitivity);
charMoveComp->bOrientRotationToMovement = charMoveComp->bUseControllerDesiredRotation = charMoveComp->bIgnoreBaseRotation = true;
PrimaryActorTick.bCanEverTick = true;
}
void AKiritoCharacter::BeginPlay()
{
Super::BeginPlay();
}
void AKiritoCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AKiritoCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis("MoveForward", this, &AKiritoCharacter::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &AKiritoCharacter::MoveRight);
PlayerInputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
PlayerInputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);
PlayerInputComponent->BindAction("Crouch", IE_Pressed, this, &AKiritoCharacter::BeginCrouch);
PlayerInputComponent->BindAction("Crouch", IE_Released, this, &AKiritoCharacter::EndCrouch);
PlayerInputComponent->BindAction("Sprint", IE_Pressed, this, &AKiritoCharacter::BeginSprint);
PlayerInputComponent->BindAction("Sprint", IE_Released, this, &AKiritoCharacter::EndSprint);
PlayerInputComponent->BindAction("SwordSwing", IE_Released, this, &AKiritoCharacter::SwingSword);
}
void AKiritoCharacter::SwingSword() {
GetMesh()->GetAnimInstance()->Montage_Play(attackMontage);
}
void AKiritoCharacter::MoveForward(float axisValue) {
MoveDir(X);
}
void AKiritoCharacter::MoveRight(float axisValue) {
MoveDir(Y);
}
void AKiritoCharacter::BeginSprint() {
GetCharacterMovement()->MaxWalkSpeed = runSpeed;
}
void AKiritoCharacter::EndSprint() {
GetCharacterMovement()->MaxWalkSpeed = walkSpeed;
}
void AKiritoCharacter::BeginCrouch() {
Crouch();
}
void AKiritoCharacter::EndCrouch() {
UnCrouch();
}
本文标签: cHow to not blend upperbody of UE51 animationsStack Overflow
版权声明:本文标题:c++ - How to not blend upper-body of UE5.1 animations - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740240876a2247331.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论