1.蓝图输出控制
2.c++输出
2.1Repor.cpp
#include "Reporter.h"
// Sets default values for this component's properties
UReporter::UReporter()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UReporter::BeginPlay()
{
Super::BeginPlay();
//获得actor指针//GetOwner()返回值是指针
AActor *Owner = GetOwner();
//.h文件#include "GameFramework/Actor.h"
FString Name= Owner->GetName();//名字
FVector Location= Owner->GetActorLocation();//位置
UE_LOG(LogTemp,Warning,TEXT("Name:%s Location:%s"),*Name,*Location.ToString ());//输出
FRotator NewRotation = FRotator(0.0F, 90.0F, 0.0F);
Owner->SetActorRotation(NewRotation);//旋转90度
}
// Called every frame
void UReporter::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
2.2Reporter.h
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "GameFramework/Actor.h"
#include "Reporter.generated.h"
//报错1.uclass在第十行 2.编译保存,developmontEider>developmnet>保存一下
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class RADARSYSTEM_API UReporter : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UReporter();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};