自学《Unreal Engine 4 游戏开发入门经典》 学习记录  

1.游戏场景搭建:
使用立方体静态网格搭建平台以及围栏,使用阻挡体积限制玩家的移动范围
 2.玩家pawn:
1.自定义射击游戏的玩家外观
2.项目设置中绑定玩家操作的输入,取消pawn 的默认运动
3.GameMode中事件开始运行时设置固定摄像机位置
4.pawn中添加自定义变量,is Damaged 判读是否收到伤害。第二次伤害游戏结束
5.添加粒子系统(受伤着火),添加受伤函数(收到伤害时产生火焰的粒子效果,is Damaged -> true)、恢复函数(拾到恢复道具消除粒子效果,is Damaged -> false)死亡函数(受伤状态再次受伤,隐藏actor,产生爆炸效果,3s后重新开始游戏)
6.添加鼠标左键射击触发函数,左键点击后,在飞船所在位置生成子弹。子弹构造和下面陨石类似,仅改变了方向以及速度
      
3.障碍物和回复道具:
1.建立一个物品基类 父类为actor (此类主要用于设置移动方向、随机物品大小和随机速度)
生成物品时随机旋转,设置3D缩放,同时设置移动速度,
在生成后每一帧都按照自己的速度向下移动
 
2.陨石
继承父类物品基类,设置静态网格(初学者素材包中的石头)
设置触发盒子,使用类型转换为(cast to)my_pawn, 当与玩家接触时调用玩家的受伤函数

3.治疗道具
继承基础物品类
添加2个立方体静态网格,组成十字架形状在中心
使用自制发光透明材质,制作恢复道具效果
设置触发盒子,使用类型转换为(cast to)my_pawn, 当与玩家接触时调用玩家的恢复函数
   4.障碍物和回复道具生成:
场景图片中固定在游戏场景外的一排actor为物品生成的actor
事件开始运行,调用生成函数,生成函数再调用定时器,再次生成
  5.UMG
使用UMG制作简单的开始界面
使用书本素材提供的图片作为背景,添加按钮,在按钮上添加输入文本,设置按钮普通、按压以及悬停的变化。
添加按压触发函数
  6.使用UMG
新建立一个关卡,新建玩家控制器蓝图类,启用鼠标光标以及点击悬停事件,事件开始时,创建开始菜单控件添加到视口,设置GameMode中的玩家控制类为新建的StartMenu__PlayController,在关卡世界场景中设置新建的GameMode和PlayerController


|