11715人加入学习
(26人评价)
【旧版】Unreal基本知识案例 - 密室逃脱

旧版课程,制作完成于2017-01-11

价格 免费

1.如何获取绑定到的Actor对象

GetOwner:从Component继承来的

也就是说归属关系已经被Actor和Component封装好了

2.如何出发开关门事件

[展开全文]

// Fill out your copyright notice in the Description page of Project Settings. #include "OpenDoor.h" #include "GameFramework/Actor.h" // Sets default values for this component's properties UOpenDoor::UOpenDoor() { // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features // off to improve performance if you don't need them. PrimaryComponentTick.bCanEverTick = true; // ... } // Called when the game starts void UOpenDoor::BeginPlay() { Super::BeginPlay(); // ... //得到所在Actor 设置这个Actor的属性 AActor* Actor = GetOwner(); // pick =y yaw = z roll= x FRotator NewRotator = FRotator(90, 0, 0); Actor->SetActorRotation(NewRotator); } // Called every frame void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); // ... }

[展开全文]

使用AActor* 需要引用的库:#include "GameFramework/Actor.h"

 

OpenDoor.cpp

void UOpenDoor::BeginPlay()

{

    Super::BeginPlay();

    // 得到所在的Actor  设置这个Actor的属性

    AActor* Actor = GetOwner();

    // pitch=y  yaw=z  roll=x

    FRotator NewRotator = FRotator(0,90.0);

    Actor->SetActorRotation(NewRotator);

}

世界大纲视图 里面的类型继承自Actor

世界大纲视图,文件多,可以创建文件夹统一管理

点击世界大纲视图里面的小眼睛,可以隐藏选中的,可以用来确保没有遗漏物体

 

命名习惯

AActor

UOpenDoor

bCanEverTick

 

Actor 是个指针,同时这还是个对象,要调用它的方法,需要使用 ->

并不是指针拥有的函数,而是对象的函数

 

在Visual Studio 保存了代码,需要在UE4编辑器的工具栏点击 【编译】

 

可以移动的物体才能旋转,需要在细节面板,变换--移动性,设置为可移动

 

显示有用的调试信息:

窗口---开发者工具---输入日志

Windows---Developer Tools---Output Log

 

每次修改完代码,记得点【编译】!!!

 

[展开全文]

16节10分钟所讲的Frotator给大家一个更好记忆的方法

UE4中的旋转角度是“姿态角”,具体查看连接

具体意义是:

俯仰角(pitch):飞机头部上下摆动

偏航角(yaw):飞机水平面上左右摆动

翻滚角(roll):顾名思义,想想你滚床单时候的姿势

[展开全文]

授课教师

SiKi学院老师

课程特色

图文(2)
视频(37)