Advertisement
Guest User

Minimum Pawn movement Setup

a guest
Nov 10th, 2017
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. //---------- Pawn H
  2. #pragma once
  3.  
  4. #include "Components/CapsuleComponent.h"
  5. #include "GameFramework/Pawn.h"
  6. #include "CustomMoveComp.h"
  7. #include "CustomPawn.generated.h"
  8.  
  9.  
  10.  
  11. UCLASS(BlueprintType, Blueprintable)
  12. class ACustomPawn : public APawn
  13. {
  14.     GENERATED_BODY()
  15.  
  16. private:
  17.  
  18.     UPROPERTY(Category = Character, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
  19.         class UCapsuleComponent* CapsuleComponent;
  20.  
  21.     UPROPERTY(Category = Character, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
  22.         class UCustomMoveComp* CustomMovement;
  23. public:
  24.  
  25.     ACustomPawn();
  26. };
  27.  
  28. //------------- Pawn CPP
  29. #include "CustomPawn.h"
  30.  
  31. ACustomPawn::ACustomPawn()
  32. {
  33.     CapsuleComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("Capsule"));
  34.     SetRootComponent(CapsuleComponent);
  35.  
  36.     CustomMovement = CreateDefaultSubobject<UCustomMoveComp>(TEXT("MovementComponent"));
  37.     CustomMovement->SetUpdatedComponent(CapsuleComponent);
  38. }
  39.  
  40.  
  41. //---------- Comp H
  42. #pragma once
  43.  
  44. #include "GameFramework/PawnMovementComponent.h"
  45. #include "CustomMoveComp.generated.h"
  46.  
  47. UCLASS(BlueprintType, Blueprintable)
  48. class UCustomMoveComp : public UPawnMovementComponent
  49. {
  50.     GENERATED_BODY()
  51.  
  52. public:
  53.     UCustomMoveComp();
  54.  
  55.     virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
  56.  
  57. };
  58.  
  59.  
  60. //------------ Comp CPP
  61. #include "CustomMoveComp.h"
  62.  
  63. UCustomMoveComp::UCustomMoveComp()
  64. {
  65.  
  66. }
  67.  
  68. void UCustomMoveComp::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
  69. {
  70.     Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
  71.  
  72.     UE_LOG(LogTemp, Warning, TEXT("Ticking Custom Move"));
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement