Guest User

FPPCharacter.h

a guest
Oct 20th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.80 KB | None | 0 0
  1. // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
  2.  
  3. #pragma once
  4.  
  5. #include "CoreMinimal.h"
  6. #include "GameFramework/Character.h"
  7. #include "FPPCharacter.generated.h"
  8.  
  9. class UInputComponent;
  10.  
  11. UCLASS(config=Game)
  12. class AFPPCharacter : public ACharacter
  13. {
  14.     GENERATED_BODY()
  15. public:
  16.     /** Pawn mesh: 1st person view (arms; seen only by self) */
  17.     UPROPERTY(VisibleDefaultsOnly, Category=Mesh)
  18.     class USkeletalMeshComponent* Mesh1P;
  19.  
  20.     /** Gun mesh: 1st person view (seen only by self) */
  21.     UPROPERTY(VisibleDefaultsOnly, Category = Mesh)
  22.     class USkeletalMeshComponent* FP_Gun;
  23.  
  24.     /** Location on gun mesh where projectiles should spawn. */
  25.     UPROPERTY(VisibleDefaultsOnly, Category = Mesh)
  26.     class USceneComponent* FP_MuzzleLocation;
  27.  
  28.     /** Gun mesh: VR view (attached to the VR controller directly, no arm, just the actual gun) */
  29.     UPROPERTY(VisibleDefaultsOnly, Category = Mesh)
  30.     class USkeletalMeshComponent* VR_Gun;
  31.  
  32.     /** Location on VR gun mesh where projectiles should spawn. */
  33.     UPROPERTY(VisibleDefaultsOnly, Category = Mesh)
  34.     class USceneComponent* VR_MuzzleLocation;
  35.  
  36.     /** First person camera */
  37.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
  38.     class UCameraComponent* FirstPersonCameraComponent;
  39.  
  40.     /** Motion controller (right hand) */
  41.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
  42.     class UMotionControllerComponent* R_MotionController;
  43.  
  44.     /** Motion controller (left hand) */
  45.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
  46.     class UMotionControllerComponent* L_MotionController;
  47.  
  48. protected:
  49.     virtual void BeginPlay();
  50.  
  51. public:
  52.     /** Base turn rate, in deg/sec. Other scaling may affect final turn rate. */
  53.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera)
  54.     float BaseTurnRate;
  55.  
  56.     /** Base look up/down rate, in deg/sec. Other scaling may affect final rate. */
  57.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera)
  58.     float BaseLookUpRate;
  59.  
  60.     /** Gun muzzle's offset from the characters location */
  61.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Gameplay)
  62.     FVector GunOffset;
  63.  
  64.     /** Projectile class to spawn */
  65.     UPROPERTY(EditDefaultsOnly, Category=Projectile)
  66.     TSubclassOf<class AFPPProjectile> ProjectileClass;
  67.    
  68.     UFUNCTION()
  69.     void CrouchStart();
  70.  
  71.     /** Sound to play each time we fire */
  72.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Gameplay)
  73.     class USoundBase* FireSound;
  74.  
  75.     /** AnimMontage to play each time we fire */
  76.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Gameplay)
  77.     class UAnimMontage* FireAnimation;
  78.  
  79.     /** Whether to use motion controller location for aiming. */
  80.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Gameplay)
  81.     uint32 bUsingMotionControllers : 1;
  82.  
  83. protected:
  84.    
  85.     /** Fires a projectile. */
  86.     void OnFire();
  87.  
  88.     /** Resets HMD orientation and position in VR. */
  89.     void OnResetVR();
  90.  
  91.     /** Handles moving forward/backward */
  92.     void MoveForward(float Val);
  93.  
  94.     /** Handles stafing movement, left and right */
  95.     void MoveRight(float Val);
  96.    
  97.     /** Handles Sprinting Movement */
  98.     void BeginSprint();
  99.     void EndSprint();
  100.    
  101.     /** Handles Crouching Movement */
  102.     void BeginCrouch();
  103.     void EndCrouch();
  104.  
  105.     /**
  106.      * Called via input to turn at a given rate.
  107.      * @param Rate  This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
  108.      */
  109.     void TurnAtRate(float Rate);
  110.  
  111.     /**
  112.      * Called via input to turn look up/down at a given rate.
  113.      * @param Rate  This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
  114.      */
  115.     void LookUpAtRate(float Rate);
  116.  
  117.     struct TouchData
  118.     {
  119.         TouchData() { bIsPressed = false;Location=FVector::ZeroVector;}
  120.         bool bIsPressed;
  121.         ETouchIndex::Type FingerIndex;
  122.         FVector Location;
  123.         bool bMoved;
  124.     };
  125.     void BeginTouch(const ETouchIndex::Type FingerIndex, const FVector Location);
  126.     void EndTouch(const ETouchIndex::Type FingerIndex, const FVector Location);
  127.     void TouchUpdate(const ETouchIndex::Type FingerIndex, const FVector Location);
  128.     TouchData   TouchItem;
  129.  
  130.    
  131. protected:
  132.     // APawn interface
  133.     virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
  134.     // End of APawn interface
  135.  
  136.     /*
  137.      * Configures input for touchscreen devices if there is a valid touch interface for doing so
  138.      *
  139.      * @param   InputComponent  The input component pointer to bind controls to
  140.      * @returns true if touch controls were enabled.
  141.      */
  142.     bool EnableTouchscreenMovement(UInputComponent* InputComponent);
  143.  
  144. public:
  145.     /** Returns Mesh1P subobject **/
  146.     FORCEINLINE class USkeletalMeshComponent* GetMesh1P() const { return Mesh1P; }
  147.     /** Returns FirstPersonCameraComponent subobject **/
  148.     FORCEINLINE class UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; }
  149.  
  150. };
Add Comment
Please, Sign In to add comment