UE4 C++ 续声明变量,输出到控制台,添加组件

只是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<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));
}

// 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);

}

**

在这里插入图片描述

嗯,就这样每天进步一点点✔

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Li~蒙一

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值