3c69445d90
- 移除跳跃逻辑:删除JumpAction、DoJumpStart/End - 调整CMC参数:MaxWalkSpeed=450, Acceleration=2250, Brake=1500, RotationRate=720 - 调整SpringArm:TargetArmLength=350, SocketOffset.Z=80, CameraLag=6, ProbeSize=12 - 添加Pitch限幅:ViewPitchMin=-30, ViewPitchMax=45, 初始俯角-15° - 新增交互状态:bIsInteracting + SetInteracting/IsInteracting/IsRunning - 新增交互IA:InteractAction/CancelAction/SwitchInteractAction(占位回调) - DoMove添加交互中忽略移动输入检查 Task: P-011
120 lines
3.6 KiB
C++
120 lines
3.6 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "GameFramework/Character.h"
|
|
#include "Logging/LogMacros.h"
|
|
#include "ChildHoodCharacter.generated.h"
|
|
|
|
class USpringArmComponent;
|
|
class UCameraComponent;
|
|
class UInputAction;
|
|
struct FInputActionValue;
|
|
|
|
DECLARE_LOG_CATEGORY_EXTERN(LogTemplateCharacter, Log, All);
|
|
|
|
/**
|
|
* A simple player-controllable third person character
|
|
* Implements a controllable orbiting camera
|
|
*/
|
|
UCLASS(abstract)
|
|
class AChildHoodCharacter : public ACharacter
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
/** Camera boom positioning the camera behind the character */
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true"))
|
|
USpringArmComponent* CameraBoom;
|
|
|
|
/** Follow camera */
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true"))
|
|
UCameraComponent* FollowCamera;
|
|
|
|
protected:
|
|
|
|
/** Move Input Action */
|
|
UPROPERTY(EditAnywhere, Category="Input")
|
|
UInputAction* MoveAction;
|
|
|
|
/** Look Input Action */
|
|
UPROPERTY(EditAnywhere, Category="Input")
|
|
UInputAction* LookAction;
|
|
|
|
/** Mouse Look Input Action */
|
|
UPROPERTY(EditAnywhere, Category="Input")
|
|
UInputAction* MouseLookAction;
|
|
|
|
/** Interact Input Action (E key) — delegates to interaction system */
|
|
UPROPERTY(EditAnywhere, Category="Input")
|
|
UInputAction* InteractAction;
|
|
|
|
/** Cancel Input Action (ESC key) — delegates to interaction system */
|
|
UPROPERTY(EditAnywhere, Category="Input")
|
|
UInputAction* CancelAction;
|
|
|
|
/** Switch Interact Target Input Action (Tab / Mouse Wheel) — delegates to interaction system */
|
|
UPROPERTY(EditAnywhere, Category="Input")
|
|
UInputAction* SwitchInteractAction;
|
|
|
|
/** Whether the character is currently in an interaction */
|
|
bool bIsInteracting = false;
|
|
|
|
public:
|
|
|
|
/** Constructor */
|
|
AChildHoodCharacter();
|
|
|
|
protected:
|
|
|
|
/** Initialize input action bindings */
|
|
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
|
|
|
protected:
|
|
|
|
/** Called for movement input */
|
|
void Move(const FInputActionValue& Value);
|
|
|
|
/** Called for looking input */
|
|
void Look(const FInputActionValue& Value);
|
|
|
|
/** Called for interact input (E) — placeholder, delegates to interaction system */
|
|
void OnInteract(const FInputActionValue& Value);
|
|
|
|
/** Called for cancel input (ESC) — placeholder, delegates to interaction system */
|
|
void OnCancel(const FInputActionValue& Value);
|
|
|
|
/** Called for switch interact target input (Tab/Wheel) — placeholder, delegates to interaction system */
|
|
void OnSwitchInteract(const FInputActionValue& Value);
|
|
|
|
public:
|
|
|
|
/** Handles move inputs from either controls or UI interfaces */
|
|
UFUNCTION(BlueprintCallable, Category="Input")
|
|
virtual void DoMove(float Right, float Forward);
|
|
|
|
/** Handles look inputs from either controls or UI interfaces */
|
|
UFUNCTION(BlueprintCallable, Category="Input")
|
|
virtual void DoLook(float Yaw, float Pitch);
|
|
|
|
/** Set interaction state — called by interaction system */
|
|
UFUNCTION(BlueprintCallable, Category="Interaction")
|
|
void SetInteracting(bool bValue);
|
|
|
|
/** Query: is the character currently interacting? */
|
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="Interaction")
|
|
bool IsInteracting() const;
|
|
|
|
/** Query: is the character currently running (moving on ground)? */
|
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="Interaction")
|
|
bool IsRunning() const;
|
|
|
|
public:
|
|
|
|
/** Returns CameraBoom subobject **/
|
|
FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
|
|
|
|
/** Returns FollowCamera subobject **/
|
|
FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; }
|
|
};
|