UE4代码片断备份

在Actor内创建一个StaticMesh

#include "Components/StaticMeshComponent.h"
#include "Engine/StaticMesh.h"
auto comp1 = CreateDefaultSubobject<UStaticMeshComponent>("Cube");
ConstructorHelpers::FObjectFinder<UStaticMesh> sm(TEXT("/Engine/BasicShapes/Cube.Cube"));
comp1->SetStaticMesh(sm.Object);
comp1->SetWorldScale3D(FVector(0.5));
comp1->SetupAttachment(RootComponent);

用UE宏实现委托

https://blog.csdn.net/yangxuan0261/article/details/52097699

1 DECLARE_DELEGATE(FTimerDelegate);
2 #define DECLARE_DELEGATE( DelegateName ) FUNC_DECLARE_DELEGATE( DelegateName, void );
3 #define FUNC_DECLARE_DELEGATE( DelegateName, ... ) \ typedef TBaseDelegate<__VA_ARGS__> DelegateName;
相当于 TBaseDelegate FTimerDelegate

KismetSystemLibrary

UKismetSystemLibrary::Delay(this, HitDelayTime, FLatentActionInfo(16, 2147483647, TEXT("方法名"), this));//这个延时执行一个方法

动态加载

LoadObject 在 Object.h内 不用找头文件了,动态加载 GO

设置模型碰撞

SMC = CreateDefaultSubobject<UStaticMeshComponent>("SMC");
ConstructorHelpers::FObjectFinder<UStaticMesh> sm(TEXT("/Game/Code/Cell/CellMs.CellMs"));//查找模型加载
SMC->SetStaticMesh(sm.Object);
SMC->AttachTo(RootComponent);
SMC->CastShadow = false;
SMC->SetCollisionProfileName(UCollisionProfile::CustomCollisionProfileName);//自定义碰撞配置文件 
SMC->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);//忽略所有通道
SMC->SetCollisionObjectType(ECollisionChannel::ECC_WorldStatic);//世界静态碰撞对象
SMC->SetCollisionResponseToChannel(ECollisionChannel::ECC_GameTraceChannel5, ECollisionResponse::ECR_Block);//使用自定义通道

其他

PlayerContorller set enable click event 启用鼠标点击事件

posted @ 2018-11-16 17:12  晨祷  阅读(697)  评论(0编辑  收藏  举报