|
|
|
|
| #pragma once
|
|
|
| #include "CoreMinimal.h"
|
| #include "GameFramework/Character.h"
|
| #include "SideScrollingCharacter.generated.h"
|
|
|
| class UCameraComponent;
|
| class UInputAction;
|
| struct FInputActionValue;
|
|
|
| |
| |
|
|
| UCLASS(abstract)
|
| class ASideScrollingCharacter : public ACharacter
|
| {
|
| GENERATED_BODY()
|
|
|
|
|
| UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category ="Camera", meta = (AllowPrivateAccess = "true"))
|
| UCameraComponent* Camera;
|
|
|
| protected:
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Input")
|
| UInputAction* MoveAction;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Input")
|
| UInputAction* JumpAction;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Input")
|
| UInputAction* DropAction;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Input")
|
| UInputAction* InteractAction;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Side Scrolling|Jump")
|
| float JumpPushImpulse = 600.0f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Side Scrolling|Interaction")
|
| float InteractionRadius = 200.0f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Side Scrolling|Wall Jump")
|
| float DelayBetweenWallJumps = 0.3f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Side Scrolling|Wall Jump")
|
| float WallJumpTraceDistance = 50.0f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Side Scrolling|Wall Jump")
|
| float WallJumpHorizontalImpulse = 500.0f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Side Scrolling|Wall Jump")
|
| float WallJumpVerticalMultiplier = 1.4f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Side Scrolling|Soft Platforms")
|
| TEnumAsByte<ECollisionChannel> SoftCollisionObjectType;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Side Scrolling|Soft Platforms")
|
| float SoftCollisionTraceDistance = 1000.0f;
|
|
|
|
|
| float LastFallTime = 0.0f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Side Scrolling|Coyote Time", meta = (ClampMin = 0, ClampMax = 5, Units = "s"))
|
| float MaxCoyoteTime = 0.16f;
|
|
|
|
|
| FTimerHandle WallJumpTimer;
|
|
|
|
|
| float ActionValueY = 0.0f;
|
|
|
|
|
| float DropValue = 0.0f;
|
|
|
|
|
| bool bHasWallJumped = false;
|
|
|
|
|
| bool bHasDoubleJumped = false;
|
|
|
|
|
| bool bMovingHorizontally = false;
|
|
|
| public:
|
|
|
|
|
| ASideScrollingCharacter();
|
|
|
| protected:
|
|
|
|
|
| virtual void EndPlay(EEndPlayReason::Type EndPlayReason) override;
|
|
|
|
|
| virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
|
|
|
|
| virtual void NotifyHit(class UPrimitiveComponent* MyComp, AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit) override;
|
|
|
|
|
| virtual void Landed(const FHitResult& Hit) override;
|
|
|
|
|
| virtual void OnMovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode = 0) override;
|
|
|
| protected:
|
|
|
|
|
| void Move(const FInputActionValue& Value);
|
|
|
|
|
| void Drop(const FInputActionValue& Value);
|
|
|
|
|
| void DropReleased(const FInputActionValue& Value);
|
|
|
| public:
|
|
|
|
|
| UFUNCTION(BlueprintCallable, Category="Input")
|
| virtual void DoMove(float Forward);
|
|
|
|
|
| UFUNCTION(BlueprintCallable, Category="Input")
|
| virtual void DoDrop(float Value);
|
|
|
|
|
| UFUNCTION(BlueprintCallable, Category="Input")
|
| virtual void DoJumpStart();
|
|
|
|
|
| UFUNCTION(BlueprintCallable, Category="Input")
|
| virtual void DoJumpEnd();
|
|
|
|
|
| UFUNCTION(BlueprintCallable, Category="Input")
|
| virtual void DoInteract();
|
|
|
| protected:
|
|
|
|
|
| void MultiJump();
|
|
|
|
|
| void CheckForSoftCollision();
|
|
|
|
|
| void ResetWallJump();
|
|
|
| public:
|
|
|
|
|
| void SetSoftCollision(bool bEnabled);
|
|
|
| public:
|
|
|
|
|
| UFUNCTION(BlueprintPure, Category="Side Scrolling")
|
| bool HasDoubleJumped() const;
|
|
|
|
|
| UFUNCTION(BlueprintPure, Category="Side Scrolling")
|
| bool HasWallJumped() const;
|
| };
|
|
|