只是UE4C++一般用的打印,输出到控制台,
UE_LOG(LogTemp,Log,TEXT("Hello World !")); UE_LOG(LogTemp, Warning, TEXT("Hello World !")); UE_LOG(LogTemp, Error, TEXT("Hello World !"));
效果:
只是UE4 C++的变量声明:
声明
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Gameframework/Actor.h" #include "MyActor.generated.h" UCLASS() class BASICTRAINING_API AMyActor : public AActor { GENERATED_BODY() public: // Sets default values for this actor's properties AMyActor(); UPROPERTY(VisibleAnywhere,Category="My Actor Components")//组件一般都给这个 UStaticMeshComponent* StaticMesh; UPROPERTY(EditInstanceOnly,Category="My Actor Pro")//这个就像蓝图实例里(可编辑)和生成公开差不多,然后Gategory这个生成时公开的属性名字 FVector IL; UPROPERTY(VisibleInstanceOnly,Category="My Actor Pro")//这个就只是公开,只能看到 FVector PL; UPROPERTY(EditDefaultsOnly,Category="My Actor Pro") //这个就不能在实例里看到,到蓝图编辑器里可以看到和修改0 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: // Called when the game starts or when spawned virtual void BeginPlay() override; public: // Called every frame virtual void Tick(float DeltaTime) override; };
创建静态网格体和摄像机:
** // Fill out your copyright notice in the Description page of Project Settings. #include "MyPawn.h" #include "Components/StaticMeshComponent.h" #include "Camera/CameraComponent.h" // Sets default values AMyPawn::AMyPawn() { // Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; RootComponent = CreateDefaultSubobject(TEXT("RootComponent")); MyStaticMesh = CreateDefaultSubobject (TEXT("MyStaticMesh")); MyStaticMesh->SetupAttachment(GetRootComponent());//附加到组件 MyCamera = CreateDefaultSubobject (TEXT("MyCamera")); MyCamera->SetupAttachment(GetRootComponent()); MyCamera->SetRelativeLocation(FVector(-300.0f,0.0f,300.0f));//设置相对位置 MyCamera->SetRelativeRotation(FRotator(-45.0f, 0.0f, 0.0f)); } // Called when the game starts or when spawned void AMyPawn::BeginPlay() { Super::BeginPlay(); } // Called every frame void AMyPawn::Tick(float DeltaTime) { Super::Tick(DeltaTime); } // Called to bind functionality to input void AMyPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent); } **
嗯,就这样每天进步一点点✔
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)