I rewrote everything I had in blueprint to c++.
Everything should be setup right, and the blueprint nodes are disconnected but I still can’t move. it doesn’t even go in the move forward function, which makes no sense to me.
//header
protected:
virtual void SetupPlayerInputComponent(UInputComponent* inputComponent) override;
/** Handles moving forward/backward */
UFUNCTION()
void MoveForward(float val);
/** Handles stafing movement, left and right */
UFUNCTION()
void MoveRight(float val);
UFUNCTION()
void TurnAtRate(float rate);
UFUNCTION()
void LookUpAtRate(float rate);
//cpp
void AMyProjectCharacter::SetupPlayerInputComponent(class UInputComponent* playerInputComponent)
{
check(playerInputComponent);
/// Input WASD
playerInputComponent->BindAxis("MoveForward", this, &AMyProjectCharacter::MoveForward);
playerInputComponent->BindAxis("MoveRight", this, &AMyProjectCharacter::MoveRight);
}
void AMyProjectCharacter::MoveForward(float value)
{
UE_LOG(LogTemp, Warning, TEXT("forward"));
if (value != 0.0f)
{
// add movement in that direction
AddMovementInput(GetActorForwardVector(), value);
this->VAxis = value;
}
}
void AMyProjectCharacter::MoveRight(float value)
{
UE_LOG(LogTemp, Warning, TEXT("sideways"));
if (value != 0.0f)
{
// add movement in that direction
AddMovementInput(GetActorRightVector(), value);
this->HAxis = value;
}
}
I don’t know what to do anymore. I’m certain it’s just some stupid mistake but I can’t seem to find it.
EDIT
I added starfekey and moveforwardkey and now it works. But why. there is not difference whatsoever.
Can someone explain that to me?