ue4

Playerの作成


アニメ用コンポーネントの追加

ACppPlyBaseにアニメーション用コンポーネントAnmStateComponentを追加し、 それを通して使ってアニメーションを制御します。

ACppPlyBaseにAnmStateComponentを追加

ヘッダCppPlyBase.hにUAnmStateComponentのポインタを追加します。
CppPlyBase.h 全文

/**
 * @file CppPlyBase.h
 * @brief プレイヤーコントローラー
 * @author     inuvatico
 * @date        2020/11/8
 * @version     1.0
 * @copyright   2020 inuvatico
 * Released under the MIT license.
 *   see https://opensource.org/licenses/MIT
 * @par (new/Add/Change : 2020/11/8)
 *
*/
#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "../../../uty/AnmStateComponent.h" //アニメーション状態コンポーネント
#include "../../../uty/AttakDamageBase.h" 
#include "CppPlyBase.generated.h"


class UAnmStateComponent;

UCLASS()
class ACppPlyBase : public ACharacter
{
    GENERATED_BODY()

public:
    // Sets default values for this character's properties
    ACppPlyBase();

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

public: 
    // Called every frame
    virtual void Tick(float DeltaTime) override;

    // Called to bind functionality to input
    virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

    UAnmStateComponent* AnmStateComponent=nullptr; //!<アニメーション
};

CppPlyBase.cpp
コンストラクタでUAnmStateComponentをCreateします。

/**
 * @file CppPlyBase.cpp
 * @brief プレイヤーコントローラー
 * @author     inuvatico
 * @date        2020/11/8
 * @version     1.0
 * @copyright   2020 inuvatico
 * Released under the MIT license.
 *   see https://opensource.org/licenses/MIT
 * @par (new/Add/Change : 2020/11/8)
 *
*/

#include "CppPlyBase.h"

// Sets default values
ACppPlyBase::ACppPlyBase()
{
    // アニメーションステートコンポーネントを連結
    AnmStateComponent = CreateDefaultSubobject<UAnmStateComponent>(TEXT("AnmStateComponent"));  
}

// Called when the game starts or when spawned
void ACppPlyBase::BeginPlay()
{
    Super::BeginPlay();
}

// Called to bind functionality to input
void ACppPlyBase::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
    Super::SetupPlayerInputComponent(PlayerInputComponent);
}  

// Called every frame
void ACppPlyBase::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
}

ACppPlyBaseの修正はここまで。
プレイヤーの制御はACppPlayerControllerで行います。

prev/next







digitalize
  始めました。