2017-03-12 9 views
0

スプリントアクションをシフトキーにバインドしようとするとエラーコードが表示されます。エラーは、オーバーロードされた関数 "UInputComponent :: BindAction"のインスタンスが引数リストと一致しないことを示します。私は何が間違っているか正確にはわかりませんが、何か助けていただければ幸いです。ありがとう。Unrealのシフトキーにスプリントアクションをバインドするときに問題があります

// Fill out your copyright notice in the Description page of Project Settings. 

#include "Guided_Exercise1.h" 
#include "Penmen.h" 


// Sets default values 
APenmen::APenmen() 
{ 
    // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it. 
    PrimaryActorTick.bCanEverTick = true; 

    GetCharacterMovement()->JumpZVelocity = 600.f; 

    bUseControllerRotationPitch = false; 
    bUseControllerRotationYaw = false; 
    bUseControllerRotationRoll = false; 

    GetCharacterMovement()->bOrientRotationToMovement = true; 

    GetCharacterMovement()->MaxWalkSpeed = 5400.f; 


} 




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

} 

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

} 

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


    //This code maps the forward, back, right, and left movement to the W, A, S, D keys that were assigned under the details section 
    //of character movement in Unreal. The values and key information is assigned in the Unreal Engine under Detail of the Character Movement pane 
    PlayerInputComponent->BindAxis("MoveForward_Key", this, &APenmen::MoveForward); 
    PlayerInputComponent->BindAxis("MoveRight_Key", this, &APenmen::MoveRight); 

    //This code makes the character jump by pressing the spacebar 
    PlayerInputComponent->BindAction("Jump_Key", IE_Pressed, this, &ACharacter::Jump); 
    PlayerInputComponent->BindAction("Jump_Key", IE_Released, this, &ACharacter::StopJumping); 

    PlayerInputComponent->BindAction("Run_Key", IE_Pressed, this, &APenmen::OnStartSprint); 
    PlayerInputComponent->BindAction("Run_Key", IE_Released, this, &APenmen::OnEndSprint); 

} 

//This method makes the character move forward and backward by pressing the W and S key 
//which were assigned in the details section of character movement in Unreal 
void APenmen::MoveForward(float Value) { 

    //UE_LOG(LogTemp, Warning, TEXT("W or S Key pressed")); 

    const FRotator Rotation = Controller->GetControlRotation(); 
    const FRotator YawRotation(0, Rotation.Yaw, 0); 

    //By using the X axis, the character will now move forward and back. It will scale along the X axis by moving forward, which 
    //has a value of 1.0, and backward, which has a value 0f -1.0. Visual Studio recieves these values from the Unreal Engine 
    const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X); 

    AddMovementInput(Direction, Value); 

} 
//This method makes the character move left and right by using the A and S key 
void APenmen::MoveRight(float Value) { 
    //UE_LOG(LogTemp, Warning, TEXT("D or A Key Pressed")); 

    const FRotator Rotation = Controller->GetControlRotation(); 
    const FRotator YawRotation(0, Rotation.Yaw, 0); 

    //By using the Y axis, the character will move along the Y axis which is left and right 
    const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y); 

    AddMovementInput(Direction, Value); 
} 

void APenmen::OnStartSprint(float Value) 
{ 

    GetCharacterMovement()->MaxWalkSpeed = 5400.f; 
} 

void APenmen::OnEndSprint(float Value) 
{ 

    GetCharacterMovement()->MaxWalkSpeed = 50.f; 

} 

そして、ここに私の.hコードです:

// Fill out your copyright notice in the Description page of Project Settings. 

    #pragma once 

    #include "GameFramework/Character.h" 
    #include "Penmen.generated.h" 

    UCLASS() 
    class GUIDED_EXERCISE1_API APenmen : public ACharacter 
    { 
     GENERATED_BODY() 

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

    protected: 
     void EndSprint(); 
     // 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; 

     //This sets up the methods for character movement and will grab the Value (1.0 for moving forward and -1.0 for moving backward from Unreal 
     //for how fast to move when the corresponding key is pressed 

     void MoveForward(float Value); 

     //This sets up the methods for character movement and will grab the Value (1.0 for moving right and -1.0 for moving left from Unreal 
     //for how fast to move when the corresponding key is pressed 
     void MoveRight(float Value); 

     void OnStartSprint(float Value); 

     void OnEndSprint(float Value); 





    }; 
+0

ようこそ:だから、ここではより詳細な情報へのリンクがあります

void OnStartSprint(); void OnEndSprint(); 

に宣言を変更する必要があります。 [The Tour](http://stackoverflow.com/tour)を読み、[ヘルプセンター](http://stackoverflow.com/help/asking)の資料を参考にしてください。ここに聞いてください。 –

+0

このような問題を解決する適切なツールは、デバッガです。スタックオーバーフローを尋ねる前に、コードを一行ずつ進める必要があります。詳しいヘルプは、[小さなプログラムをデバッグする方法(Eric Lippert)](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/)を参照してください。最低限、問題を再現する[最小、完全、および検証可能](http://stackoverflow.com/help/mcve)の例と、その問題を再現するためのデバッガ。 –

+0

よく見える、入力バインディングのスペルチェック – LumbusterTick

答えて

1

問題は対照的に、アクションコールバックがコールバックを軸に、任意の引数を取ることはありません

void OnStartSprint(float Value); 
void OnEndSprint(float Value); 

の宣言です。これは、軸とアクションの違いについて考えると意味があります。軸には一定の値、すなわち親指をどれだけ押し込むかを指定できます。アクションはバイナリで、ボタンは押されているかどうかのどちらかです。スタックオーバーフローへhttps://www.unrealengine.com/blog/input-action-and-axis-mappings-in-ue4

関連する問題