UE4学习笔记14th:组件和碰撞
来源:互联网 发布:阿里云网站客服 编辑:程序博客网 时间:2024/06/05 07:13
创建项目,命名为HowTo_Components
创建新的C++类,以Pawn为夫类,命名为CollidingPawn
在CollidingPawn.h里添加:
//追溯粒子系统组件UParticleSystemComponent *OurParticleSystem;
//创建一个可以对物理行为进行响应的球体根组件USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));RootComponent = SphereComponent;SphereComponent->InitSphereRadius(40.0f);SphereComponent->SetCollisionProfileName(TEXT("Pawn"));//
//创建并放置网格组件,这样我们能看到球体的位置UStaticMeshComponent* SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation"));SphereVisual->AttachTo(RootComponent);static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere"));if (SphereVisualAsset.Succeeded()){SphereVisual->SetStaticMesh(SphereVisualAsset.Object);SphereVisual->SetRelativeLocation(FVector(0.0f, 0.0f, -40.0f));SphereVisual->SetWorldScale3D(FVector(0.8f));}
//创建粒子系统,供我们激活或反激活OurParticleSystem = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("MovementParticles"));OurParticleSystem->AttachTo(SphereVisual);OurParticleSystem->bAutoActivate = false;OurParticleSystem->SetRelativeLocation(FVector(-20.0f, 0.0f, 20.0f));static ConstructorHelpers::FObjectFinder<UParticleSystem> ParticleAsset(TEXT("/Game/StarterContent/Particles/P_Fire.P_Fire"));if (ParticleAsset.Succeeded()){OurParticleSystem->SetTemplate(ParticleAsset.Object);}
//使用弹簧臂使相机平滑、自然的运动
USpringArmComponent* SpringArm = CreateDefaultSubobject(TEXT(“CameraAttachmentArm”));
SpringArm->AttachTo(RootComponent);
SpringArm->RelativeRotation = FRotator(-45.f, 0.f, 0.f);
SpringArm->TargetArmLength = 400.0f;
SpringArm->bEnableCameraLag = true;
SpringArm->CameraLagSpeed = 3.0f;
//创建相机并附加到弹簧臂UCameraComponent* Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("ActualCamera"));Camera->AttachTo(SpringArm, USpringArmComponent::SocketName);////控制默认玩家AutoPossessPlayer = EAutoReceiveInput::Player0;//
现在我们新建的Pawn附加好了Component,并且可以进行配置以用于用户控制,我们现在返回编辑器。
阅读全文
0 0
- UE4学习笔记14th:组件和碰撞
- UE4学习笔记14th
- UE4学习笔记4th
- UE4学习笔记5th
- UE4学习笔记6th
- UE4学习笔记7th
- UE4学习笔记8th
- UE4学习笔记9th
- UE4学习笔记10th
- UE4学习笔记11th
- UE4学习笔记12th
- UE4学习笔记13th
- UE4学习笔记15th
- UE4学习笔记16th
- UE4学习笔记17th
- UE4学习笔记18th
- UE4学习笔记19th
- UE4学习笔记20th
- pnp4nagios画图出现 XML file XXXX not found 问题
- maven如何引入自定义jar或第三方jar
- Java高级软件工程师面试题
- 【USACO TRAINING】子集的和
- rn笔记:关于const {val} 与 const val
- UE4学习笔记14th:组件和碰撞
- 嵌入式高效编程小技巧
- WPF 实现数据结构对象与UI控件的绑定
- python中PIL安装教程
- ActiveMQ的network connectors部署集群(七)
- json接口测试工具json-server
- Mysql学习之索引介绍及其原理
- web请求:servlet处理请求
- 剑指offer_数组---连续子数组的最大和