Advertisement
Guest User

ClientPawn.h

a guest
Apr 30th, 2021
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.52 KB | None | 0 0
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2.  
  3. #pragma once
  4.  
  5. #include "CoreMinimal.h"
  6. #include "GameFramework/Pawn.h"
  7. #include "Components/StaticMeshComponent.h"
  8. #include "GameFramework/SpringArmComponent.h"
  9. #include "Camera/CameraComponent.h"
  10. #include "Net/UnrealNetwork.h"
  11. #include "ClientPawn.generated.h"
  12.  
  13. UCLASS()
  14. class NETPROJECT_API AClientPawn : public APawn
  15. {
  16.     GENERATED_BODY()
  17.  
  18. public:
  19.     // Sets default values for this pawn's properties
  20.     AClientPawn();
  21.  
  22.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Meshes")
  23.         UStaticMeshComponent* mainMesh;
  24.     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Camera")
  25.         USpringArmComponent* springArm;
  26.     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Camera")
  27.         UCameraComponent* camera;
  28.  
  29.     UPROPERTY()
  30.         FVector CameraInput;
  31.     UPROPERTY()
  32.         FVector MovementInput;
  33.  
  34.     UPROPERTY()
  35.         FVector ClientLocation;
  36.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated)
  37.         float moveForward;
  38.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated)
  39.         float moveRight;
  40.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated)
  41.         FVector ActorServerLocation;
  42.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated)
  43.         FRotator ActorServerRotation;
  44.  
  45.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Editable Values")
  46.         float turnSpeed;
  47.  
  48.  
  49.     UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite, Category = "Editable Values")
  50.         float walkSpeed;
  51.  
  52.     UFUNCTION(Reliable, Server)
  53.         void MoveRightServer(float Value);
  54.     UFUNCTION(Reliable, Server)
  55.         void MoveForwardServer(float Value);
  56.     UFUNCTION(Reliable, Server)
  57.         void ChangeWalkSpeed();
  58.  
  59.     UFUNCTION()
  60.     void CameraMovement(float SensitivityX, float SensitivityY);
  61.  
  62.     UFUNCTION()
  63.     void PlayerMovement();
  64.  
  65. protected:
  66.     // Called when the game starts or when spawned
  67.     virtual void BeginPlay() override;
  68.     virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
  69.  
  70. public:
  71.     // Called every frame
  72.     virtual void Tick(float DeltaTime) override;
  73.  
  74.     // Called to bind functionality to input
  75.     virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
  76.  
  77. private:
  78.     UFUNCTION(BlueprintCallable)
  79.         void PitchCamera(float Value);
  80.  
  81.     UFUNCTION(BlueprintCallable)
  82.         void YawCamera(float Value);
  83.    
  84.     UFUNCTION(BlueprintCallable)
  85.         void MoveForward(float Value);
  86.  
  87.     UFUNCTION(BlueprintCallable)
  88.         void MoveRight(float Value);
  89.  
  90.     UFUNCTION(BlueprintCallable)
  91.         void TestInput();
  92. };
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement