Skip to content

Instantly share code, notes, and snippets.

Created November 26, 2016 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/afbca815002c1d8b384df351ed57b5df to your computer and use it in GitHub Desktop.
Save anonymous/afbca815002c1d8b384df351ed57b5df to your computer and use it in GitHub Desktop.
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameButton.h"
#include "Ball.h"
#include "BaseIOActor.h"
#include "GameFramework/Character.h"
#include "PortChar.generated.h"
UCLASS()
class PORTFOLIO_API APortChar : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character's properties
APortChar();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick(float DeltaSeconds) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
//handles input for moving forward
UFUNCTION()
void MoveForward(float Value);
//handles input for moving right and left
UFUNCTION()
void MoveRight(float Value);
//starts the jump
UFUNCTION()
void OnStartJump();
//ends the jump
UFUNCTION()
void OnStopJump();
//plays when the player lands
UFUNCTION()
virtual void Landed(const FHitResult &Hit);
//set up camera shake attributes
//shaking on the x axis
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera Shakes")
TSubclassOf<UCameraShake> CameraShakeX;
//shaking on the y axis
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera Shakes")
TSubclassOf<UCameraShake> CameraShakeY;
//shaking when sprinting
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera Shakes")
TSubclassOf<UCameraShake> SprintCameraShake; //shaking x axis when sprinting
//functions to start and stop sprinting.
UFUNCTION()
void StartSprint();
UFUNCTION()
void StopSprint();
//functions to starty and stop crouching
UFUNCTION()
void StartCrouch();
UFUNCTION()
void StopCrouch();
UFUNCTION()
void CrouchImpl(float DeltaTime);
//the rate at which the footsteps play when walking
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Move Rates")
float WalkRate;
//the rate at which the footsteps play when sprinting
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Move Rates")
float SprintRate;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Move Rates")
float CrouchRate;
//the sound of footsteps on grass
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sound Cues")
USoundBase* StepSoundGrass;
//the sound of footsteps on snow
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sound Cues")
USoundBase* StepSoundSnow;
//the sound of footsteps on stone
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sound Cues")
USoundBase* StepSoundStone;
//the sound of footsteps on tile
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sound Cues")
USoundBase* StepSoundTile;
//Random Piano sound cause I loved the sound of it//////// DEPRECATED
//UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sound Cues")
// USoundBase* PianoSound;
//the sound that plays when the player jumps on grass
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sound Cues")
USoundBase* JumpSoundSnow;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sound Cues")
USoundBase* JumpSoundStone;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sound Cues")
USoundBase* JumpSoundTile;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sound Cues")
USoundBase* LandSoundTile;
//stone physical material
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Physical Materials")
UPhysicalMaterial* StoneMat;
//snow physical material
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Physical Materials")
UPhysicalMaterial* SnowMat;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Physical Materials")
UPhysicalMaterial* GrassMat;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Physical Materials")
UPhysicalMaterial* TileMat;
//crouch speed
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Move Speeds")
float CrouchSpeed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Move Speeds")
float WalkSpeed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Move Speeds")
float SprintSpeed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Input Actor")
ABaseIOActor* ActorToInteractWith;
//setup the timer function
void PlayFootsteps();
//play sound
void PlaySound();
//restart timer
void StepTimerExpired();
//plays the piano sound
// void PlayPiano();
void Interaction();
UPROPERTY(EditAnywhere)
ABall* Ball;
private:
bool isRunning; //if the player wants to sprint by holding the shift key
float stepRate; //rate the timer uses.
uint32 bCanStep : 1; //value for the timer to set
FTimerHandle TimerHandle_StepRate; //name of the timer handle
UWorld* World; //world. duh
APlayerCameraManager* PlayerCamera; //obvious playercamera is obvious
bool isMovingForward; //is the player moving forward
int StepType; //0 is stone, 1 is snow
bool isMovingForwardOrBack; //is the player pressing w or s
bool isMovingLeftOrRight; //is the player pressing a or d
bool isMoving; //if the player is moving normally
FCollisionQueryParams RV_TraceParams; //sets up parameters for the line trace
FCollisionQueryParams RV_ForwardParams;
FHitResult RV_ForwardHit;
protected:
//temp
float DecBEH;
float DecCapsHeight;
bool bIsCrouching;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment