100 lines
2.9 KiB
C++
100 lines
2.9 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "GameFramework/Pawn.h"
|
|
#include "../../../../Plugins/EnhancedInput/Source/EnhancedInput/Public/InputActionValue.h"
|
|
#include "Components/PrimitiveComponent.h"
|
|
#include "Engine/HitResult.h"
|
|
#include "MyGameModeBase.h"
|
|
#include "RollaBallPlayer.generated.h"
|
|
|
|
class USpringArmComponent;
|
|
class UCameraComponent;
|
|
class UInputAction;
|
|
class AActor;
|
|
class USphereComponent;
|
|
class URollaBallWidget;
|
|
class USplineComponent;
|
|
class ALevelManager;
|
|
|
|
UCLASS()
|
|
class TUTOBEGGINER_API ARollaBallPlayer : public APawn
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
// Sets default values for this pawn's properties
|
|
ARollaBallPlayer();
|
|
|
|
protected:
|
|
// Called when the game starts or when spawned
|
|
virtual void BeginPlay() override;
|
|
virtual void Tick( float DeltaSeconds ) override;
|
|
|
|
//Define Components
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
|
|
USphereComponent* Sphere;
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
|
|
USphereComponent* SphereTrigger;
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
|
|
UStaticMeshComponent* Mesh;
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
|
|
USpringArmComponent* SpringArm;
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
|
|
UCameraComponent* Camera;
|
|
|
|
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components")
|
|
AMyGameModeBase* GameManager;
|
|
|
|
//VARIABLES
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
float MoveForce= 500.0f;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
float JumpImpulse = 500.0f;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
int32 MaxJumpCount = 1;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
int32 JumpCount = 0;
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
|
|
UInputAction* JumpAction;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
|
|
UInputAction* MoveAction;
|
|
|
|
public:
|
|
|
|
// Called to bind functionality to input
|
|
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
|
|
|
UFUNCTION()
|
|
void OnHittt( UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit );
|
|
|
|
UFUNCTION()
|
|
void OnLeavingFloor( UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex );
|
|
|
|
UFUNCTION()
|
|
void OnEnterFloor( UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult );
|
|
|
|
private:
|
|
|
|
//FUNCTIONS
|
|
void MoveRight( float value );
|
|
void MoveForward( const FInputActionValue& Value );
|
|
void JumpFct( const FInputActionValue& Value );
|
|
|
|
bool bIsOnGround = false;
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
URollaBallWidget* pWidgetRef;
|
|
|
|
ALevelManager* LevelManager;
|
|
USplineComponent* Spline;
|
|
|
|
float Progress = 0.5f;
|
|
|
|
float MaxSplineDistance = 0.f;
|
|
};
|