只是UE4C++一般用的打印,输出到控制台,
UE_LOG(LogTemp,Log,TEXT("Hello World !"));
UE_LOG(LogTemp, Warning, TEXT("Hello World !"));
UE_LOG(LogTemp, Error, TEXT("Hello World !"));
效果:
只是UE4 C++的变量声明:
声明
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"
UCLASS()
class BASICTRAINING_API AMyActor : public AActor
{
GENERATED_BODY()
public:
AMyActor();
UPROPERTY(VisibleAnywhere,Category="My Actor Components")
UStaticMeshComponent* StaticMesh;
UPROPERTY(EditInstanceOnly,Category="My Actor Pro")
FVector IL;
UPROPERTY(VisibleInstanceOnly,Category="My Actor Pro")
FVector PL;
UPROPERTY(EditDefaultsOnly,Category="My Actor Pro")
bool bflog;
UPROPERTY(VisibleDefaultsOnly, Category = "My Actor Pro")
FVector WO;
UPROPERTY(EditAnywhere, Category = "My Actor Pro", meta = (ClampMin = -5.0f, ClampMax = 5.0f, UIMin = -5.0f, UIMax = 5.0f))
FVector TLO;
UPROPERTY(EditAnywhere, Category = "My Actor Pro")
bool bSM;
UPROPERTY(EditInstanceOnly, Category = "My Actor Pro | Physics")
FVector IF;
UPROPERTY(EditInstanceOnly, Category = "My Actor Pro | Physics")
FVector IT;
UPROPERTY(EditInstanceOnly, Category = "My Actor Pro |Physics")
bool BAC;
protected:
virtual void BeginPlay() override;
public:
virtual void Tick(float DeltaTime) override;
};
创建静态网格体和摄像机:
**
#include "MyPawn.h"
#include "Components/StaticMeshComponent.h"
#include "Camera/CameraComponent.h"
AMyPawn::AMyPawn()
{
PrimaryActorTick.bCanEverTick = true;
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
MyStaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MyStaticMesh"));
MyStaticMesh->SetupAttachment(GetRootComponent());
MyCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("MyCamera"));
MyCamera->SetupAttachment(GetRootComponent());
MyCamera->SetRelativeLocation(FVector(-300.0f,0.0f,300.0f));
MyCamera->SetRelativeRotation(FRotator(-45.0f, 0.0f, 0.0f));
}
void AMyPawn::BeginPlay()
{
Super::BeginPlay();
}
void AMyPawn::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AMyPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
**
嗯,就这样每天进步一点点?
|