When doing the fps project, the character moves the chapter and finds that the character cannot move when the play button is clicked. Below is my code.
AFpsTestCharacter::AFpsTestCharacter()
{
// 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;
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 1, FColor::Green , TEXT(“TEST11”));
}
}
// Called when the game starts or when spawned
void AFpsTestCharacter::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AFpsTestCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AFpsTestCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis(“MoveForward”, this, &AFpsTestCharacter::MoveForward);
PlayerInputComponent->BindAxis(“MoveLeft”, this, &AFpsTestCharacter::MoveForward);
}
void AFpsTestCharacter::MoveForward(float val)
{
if (val != 0.0f)
{
// Add movement in the actors forward direction. Use the axis scale value as the scale of movement to add
AddMovementInput(GetActorForwardVector(), val);
}
}
void AFpsTestCharacter::MoveLeft(float val)
{
if (val != 0.0f)
{
// Add movement in the actors forward direction. Use the axis scale value as the scale of movement to add
AddMovementInput(GetActorForwardVector(), val);
}
}
After testing MoveLeft this method has been called, and val is not 0, but the role does not move after calling AddMovementInput this method, I hope that the omnipotent netizens can help find the cause of this problem, thank you