ElGringoLoco

UE4 Basic Component [Unexpected warnings in Xcode]

Aug 21st, 2017
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.91 KB | None | 0 0
  1. /*--- PositionReport.h ---*/
  2. #pragma once
  3.  
  4. #include "CoreMinimal.h"
  5. #include "Gameframework/Actor.h"
  6. #include "Components/ActorComponent.h"
  7. #include "PositionReport.generated.h"
  8.  
  9.  
  10. UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
  11. class BUILDINGESCAPE_API UPositionReport : public UActorComponent
  12. {
  13.     GENERATED_BODY()
  14.  
  15. public:
  16.     // Sets default values for this component's properties
  17.     UPositionReport();
  18.  
  19. protected:
  20.     // Called when the game starts
  21.     virtual void BeginPlay() override;
  22.  
  23. public:
  24.     // Called every frame
  25.     virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
  26. };
  27. /*--- /PositionReport.h ---*/
  28.  
  29. /*--- PositionReport.cpp ---*/
  30. #include "PositionReport.h"
  31.  
  32.  
  33. // Sets default values for this component's properties
  34. UPositionReport::UPositionReport()
  35. {
  36.     // Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
  37.     // off to improve performance if you don't need them.
  38.     PrimaryComponentTick.bCanEverTick = true;
  39.  
  40.     // ...
  41. }
  42.  
  43.  
  44. // Called when the game starts
  45. void UPositionReport::BeginPlay()
  46. {
  47.     Super::BeginPlay(); // `BeginPlay()`: Cannot initialize object parameter of type 'UActorComponent' with an expression of type 'UPositionReport'
  48.  
  49.     FString ObjectName = GetOwner()->GetName(); // `GetOwner()` Cannot initialize object parameter of type 'const UActorComponent' with an expression of type 'UPositionReport'
  50.     FString ObjectLocationStr = GetOwner()->GetActorLocation().ToString();
  51.     UE_LOG(LogTemp, Warning, TEXT("%s is reporting duty on %s!"), *ObjectName, *ObjectLocationStr);
  52.    
  53. }
  54.  
  55.  
  56. // Called every frame
  57. void UPositionReport::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
  58. {
  59.     Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
  60.  
  61.     // ...
  62. }
  63. /*--- /PositionReport.cpp ---*/
Add Comment
Please, Sign In to add comment