Files
Yamato/Source/MyProject3/SpaceshipPawn.h
2025-02-16 23:09:20 +05:30

84 lines
2.5 KiB
C++

#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "InputActionValue.h"
#include "SpaceshipPawn.generated.h"
UCLASS()
class MYPROJECT3_API ASpaceshipPawn : public APawn
{
GENERATED_BODY()
public:
ASpaceshipPawn();
virtual void Tick(float DeltaTime) override;
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
protected:
virtual void BeginPlay() override;
// Components
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
class UStaticMeshComponent* ShipMesh;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
class USpringArmComponent* CameraSpringArm;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
class UCameraComponent* Camera;
// Enhanced Input Components
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
class UInputMappingContext* DefaultMappingContext;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
class UInputAction* ThrottleAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
class UInputAction* MouseLookAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
class UInputAction* FireAction;
// Movement Parameters
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
float MaxThrust = 2000.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
float ThrustAcceleration = 500.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
float ThrustDeceleration = 500.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
float RotationSpeed = 100.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
float MouseSensitivity = 2.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
float DragCoefficient = 0.05f;
// Input functions
void HandleThrottleStarted(const FInputActionValue& Value);
void HandleThrottleReleased(const FInputActionValue& Value);
void HandleMouseLook(const FInputActionValue& Value);
void HandleFire(const FInputActionValue& Value);
private:
// Movement state
float CurrentThrust;
float TargetThrust;
bool bThrottlePressed;
FVector CurrentVelocity;
FRotator TargetRotation;
float CurrentPitch;
float CurrentYaw;
APlayerController* PlayerControllerRef;
FVector2D MouseDeltaSmoothed;
FVector2D LastMouseDelta;
float MouseSmoothingSpeed = 10.0f;
};