Files
lonese/Source/lonese/MyCharacter.h
2026-03-15 01:39:06 +08:00

56 lines
1.8 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "MyCharacter.generated.h"
UCLASS()
class LONESE_API AMyCharacter : public ACharacter
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
class UInputMappingContext* DefaultMapping;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
class UInputAction* MoveAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
class UInputAction* RunAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
class UInputAction* CrouchAction;
UFUNCTION(BlueprintCallable, Category = "Move")
void Move(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable, Category = "Move")
void BeginRun(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable, Category = "Move")
void StopRun(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable, Category = "Move")
void BeginCrouch(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable, Category = "Move")
void StopCrouch(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable, Category = "State")
bool IsRunning() const { return bIsRunning; }
UFUNCTION(BlueprintCallable, Category = "State")
bool IsCrouching() const { return bIsCrouching; }
// Sets default values for this character's properties
AMyCharacter();
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
private:
bool bIsRunning = false;
bool bIsCrouching = false;
};