[strong text] [1]旨在得到此错误
错误:-(没有重载函数的实例与“ U Input Component :: Bind Action”参数列表匹配)
我尽我所能解决这个问题的所有可能性,请帮忙
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/InputComponent.h"
#include "GameFramework/Character.h"
#include "FPSCharacter.generated.h"
UCLASS()
class FPSPROJECT_API AFPSCharacter : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character's properties
AFPSCharacter();
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;
UFUNCTION()
void MoveForward(float Value);
UFUNCTION()
void MoveRight(float Value);
//Set jump flag when key is pressed
UFUNCTION()
void StartJump(float Value);
//Clear jump flag when key is relesed
UFUNCTION()
void StopJump(float Value);
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "FPSCharacter.h"
#include "Engine.h"
#include "Components/InputComponent.h"
#include "Components/InputComponent.h"
// Sets default values
AFPSCharacter::AFPSCharacter()
{
// 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;
}
// Called when the game starts or when spawned
void AFPSCharacter::BeginPlay()
{
Super::BeginPlay();
if (GEngine)
{
// Display a debug message for five seconds.
// The -1 "Key" value (first argument) indicates that we will never need to update or refresh this message.
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("Iam ur char 1"));
}
}
// Called every frame
void AFPSCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AFPSCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
//set up "Player Movement" binding
PlayerInputComponent->BindAxis("MoveForward", this, &AFPSCharacter::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &AFPSCharacter::MoveRight);
// Set up "look" bindings.
PlayerInputComponent->BindAxis("MouseTurn", this, &AFPSCharacter::AddControllerYawInput);
PlayerInputComponent->BindAxis("MouseLookUp", this, &AFPSCharacter:: AddControllerPitchInput);
//Seting "jump action" conduction
PlayerInputComponent->BindAction(FName("Jump"), IE_Pressed, this, &AFPSCharacter::StartJump);
PlayerInputComponent->BindAction(FName("Jump"), IE_Released, this,&AFPSCharacter::StopJump);
}
void AFPSCharacter::MoveForward(float Value)
{
// Find out which way is "forward" and record that the player wants to move that way.
FVector Direction = FRotationMatrix(Controller->GetControlRotation()).GetScaledAxis(EAxis::X);
AddMovementInput(Direction, Value);
}
void AFPSCharacter::MoveRight(float Value)
{
// Find out which way is "right" and record that the player wants to move that way.
FVector Direction = FRotationMatrix(Controller->GetControlRotation()).GetScaledAxis(EAxis::Y);
AddMovementInput(Direction, Value);
}
void AFPSCharacter::StartJump(float Value)
{
bPressedJump = true;
}
void AFPSCharacter::StopJump(float Value)
{
bPressedJump = false;
}
错误出现在
PlayerInputComponent->BindAction(FName("Jump"), IE_Pressed, this, &AFPSCharacter::StartJump);
PlayerInputComponent->BindAction(FName("Jump"), IE_Released, this,&AFPSCharacter::StopJump);
错误:-(没有重载函数的实例与参数列表的“ U Input Component :: Bind Action”匹配)在(->)这个指针上>
[[strong文本] [1]旨在得到此错误错误:-(没有重载函数的实例与“ U Input Component :: Bind Action”参数列表匹配”),我尝试了所有无法摆脱的可能性...
[据我所知,您正在尝试使用虚幻引擎进行编码。通常,该错误似乎表明您的BindAction()
方法要么参数数量错误,要么在某处接收到错误类型的参数。
您的方法StartJump
和StopJump
是action