2017-03-12 1 views
0

Ich erhalte einen Fehlercode beim Versuch, eine Sprintaktion an die Umschalttaste zu binden. Die Fehlerzustände, keine Instanz von überladenen Funktionen "UInputComponent :: BindAction" stimmt mit der Argumentliste überein. Ich bin mir nicht sicher, was genau falsch ist, aber jede Hilfe würde geschätzt werden. Vielen Dank.Ich habe Probleme beim Binden einer Sprintaktion an die Umschalttaste in 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; 

} 

Und hier ist mein .h Code:

// 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

Willkommen bei Stack-Überlauf. Bitte nehmen Sie sich die Zeit, [The Tour] (http://stackoverflow.com/tour) zu lesen und beziehen Sie sich auf das Material aus der [Hilfe] (http://stackoverflow.com/help/asking), was und wie Sie können fragen Sie hier. –

+0

Das richtige Werkzeug, um solche Probleme zu lösen, ist Ihr Debugger. Sie sollten Schritt für Schritt durch Ihren Code * gehen, bevor Sie auf Stack Overflow nachfragen. Für weitere Hilfe lesen Sie bitte [Wie kleine Programme zu debuggen (von Eric Lippert)] (https://ericlippert.com/2014/03/05/how-to-debug-small-programs/). Zumindest sollten Sie Ihre Frage bearbeiten, um ein [minimales, vollständiges und verifizierbares] (http://stackoverflow.com/help/mcve) Beispiel einzufügen, das Ihr Problem zusammen mit den Beobachtungen, die Sie in der Debugger. –

+0

gut sieht gut aus, überprüfen Sie die Schreibweisen für die Eingabe-Bindungen – LumbusterTick

Antwort

1

Das Problem ist die Erklärung von

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

Aktion Rückrufe haben keine Argumente nehmen, im Gegensatz Rückrufe zur Achse. Dies macht Sinn, wenn Sie an den Unterschied zwischen Achsen und Aktionen denken. Achsen können einen bestimmten Wert haben, d. H. Wie weit dein Daumenstift gedrückt wird. Aktionen sind binär, Ihre Schaltfläche ist entweder gedrückt oder nicht. So müssen Sie die Erklärung zu

void OnStartSprint(); 
void OnEndSprint(); 

Hier ändern ist ein Link für weitere Informationen: https://www.unrealengine.com/blog/input-action-and-axis-mappings-in-ue4

Verwandte Themen