feat: 增加跑动共嗯那个

This commit is contained in:
meishibiezb
2026-03-15 01:05:25 +08:00
parent abc7730d94
commit f5767bb654
5 changed files with 17 additions and 4 deletions

View File

@@ -5,6 +5,7 @@
#include "EnhancedInputSubsystems.h"
#include "EnhancedInputComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
void AMyCharacter::Move(const FInputActionValue& Value)
{
@@ -18,10 +19,12 @@ void AMyCharacter::Move(const FInputActionValue& Value)
void AMyCharacter::BeginRun(const FInputActionValue& Value)
{
bIsRunning = true;
GetCharacterMovement()->MaxWalkSpeed = 1200.0f;
}
void AMyCharacter::StopRun(const FInputActionValue& Value)
{
bIsRunning = false;
GetCharacterMovement()->MaxWalkSpeed = 600.0f;
}
// Sets default values
@@ -68,6 +71,10 @@ void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCompone
if (MoveAction) {
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AMyCharacter::Move);
}
if (RunAction) {
EnhancedInputComponent->BindAction(RunAction, ETriggerEvent::Started, this, &AMyCharacter::BeginRun);
EnhancedInputComponent->BindAction(RunAction, ETriggerEvent::Completed, this, &AMyCharacter::StopRun);
}
}
}