教程链接:Unreal Engine 4 虚幻引擎蓝图中级教程物理碰撞

想共享的小伙伴可以E-mail我:lxbcolorgalaxy@qq.com

目录

第一章 常见的物理现象及分析

1蓝图模板中的物理现象

2创建子弹抛射

3自动追踪

4碰撞事件

5纯物理模拟子弹

第二章 碰撞体

1简易碰撞体

2DOP碰撞体

3凸面碰撞体

4567UBX导入碰撞体

8从其他模型复制碰撞体

9碰撞体积

第三章 物理刚体

1物理刚体

2质量

3质心

4运动衰减

6运动空间锁定

第四章 碰撞通道

1类型、反馈、通道

2UE4中的碰撞设置

3碰撞案例测试

4类型与反馈案例

5添加自定义碰撞

第五章 碰撞事件

1ACTOR交叉触发

2OnComponent触发

3击中

4击伤事件

5伤害类型

6点伤害

7范围伤害规则

8完全伤害

第六章 射线检测

1零粗细(很细)射线检测

2零检测返回结果

4球体非零粗细检测

5调试检测结果

6多重零粗细检测

7盒子、胶囊体检测

8逐多边形检测


第一章 常见的物理现象及分析

1蓝图模板中的物理现象

分析了第一人称射击模板中的物理现象,比如子弹飞行、碰撞、产生力的效果与消失。

2创建子弹抛射

1.给子弹击中物体施加一个同方向的冲击力——子弹蓝图

2.子弹模型添加Projectile Movement Component组件,引擎自带的子弹模拟,可设置子弹参数

3.控制生成的子弹位置、播放角色动画

3自动追踪

1.设置子弹反弹参数

2.设置子弹追踪导航功能

蓝图中设置追踪目标

4碰撞事件

1.Overlap重叠事件(类似Unity里的触发器,又不同)两者均需要勾选Generate Overlap

5纯物理模拟子弹

1.删除projectile组件,更改Sphere Mesh的碰撞预设,给小球生成时添加Physics Linear Velocity,更改发射方向。

2.选中Actor,修改生命周期

第二章 碰撞体

1简易碰撞体

2DOP碰撞体

10DOP分别沿着X Y Z轴创建更复杂的碰撞体

3凸面碰撞体

4567UBX导入碰撞体

3DMAX中制作碰撞体的命名规则:盒型UBX、球形USP、不规则UCX,紧跟其中一个模型的名称。不规则时,每个内角要小于180°,是一个凸边形。

8从其他模型复制碰撞体

选中其他已有碰撞体的相同模型,在无碰撞体的模型中选择Copy

9碰撞体积

Blocking Volume通常当作场景的边界碰撞盒,可同BSP模型一样进行编辑修改

第三章 物理刚体

1物理刚体

2质量

3质心

4运动衰减

6运动空间锁定

第四章 碰撞通道

1类型、反馈、通道

Object Type ——> Response ——> Channel

2UE4中的碰撞设置

3碰撞案例测试

1.阴影烘培效果,Movable是实时的,Static需要构建

2.可破坏物体 设置碰撞时可破碎

3.各种Object Response设置

4类型与反馈案例

5添加自定义碰撞

第五章 碰撞事件

1ACTOR交叉触发

Event ActorBeginOverlap——碰撞物体触发

Event ActorEndOverlap

2OnComponent触发

Add On Component Begin Overlap——碰撞组件触发

Add On Component End Overlap

3击中

Event Hit

开启Hit事件 碰撞响应要设置为Block

4击伤事件

1.应用伤害Apply Damage

2.接受伤害

Event AnyDamage

Event PointDamage

Event RadialDamage

5伤害类型

1.DamageType的预设类别

2.创建一个继承DamageType的自定义DamageType蓝图

3.代替Add Impulse产生冲击力,设置Damage Type中的Damage Impulse为80。但Apply Damage无法触发代码Add Impluse At Location(Apply Point/Radial Damage可以)。

AnyDamage连接下的

6点伤害

1.子弹蓝图里触发Damage

7范围伤害规则

1.球形范围伤害

2.由于Damage Prevention Channel的原因,侧面和后面的方块受到的爆破力被阻碍

8完全伤害

1.C++引擎源码中的ApplyRadialDamge蓝图节点信息

h头文件

/** Hurt locally authoritative actors within the radius. Will only hit components that block the Visibility channel.* @param BaseDamage - The base damage to apply, i.e. the damage at the origin.* @param Origin - Epicenter of the damage area.* @param DamageRadius - Radius of the damage area, from Origin* @param DamageTypeClass - Class that describes the damage that was done.* @param DamageCauser - Actor that actually caused the damage (e.g. the grenade that exploded).  This actor will not be damaged and it will not block damage.* @param InstigatedByController - Controller that was responsible for causing this damage (e.g. player who threw the grenade)* @param bFullDamage - if true, damage not scaled based on distance from Origin* @param DamagePreventionChannel - Damage will not be applied to victim if there is something between the origin and the victim which blocks traces on this channel* @return true if damage was applied to at least one actor.*/UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category="Game|Damage", meta=(WorldContext="WorldContextObject", AutoCreateRefTerm="IgnoreActors"))static bool ApplyRadialDamage(const UObject* WorldContextObject, float BaseDamage, const FVector& Origin, float DamageRadius, TSubclassOf<class UDamageType> DamageTypeClass, const TArray<AActor*>& IgnoreActors, AActor* DamageCauser = NULL, AController* InstigatedByController = NULL, bool bDoFullDamage = false, ECollisionChannel DamagePreventionChannel = ECC_Visibility);/** Hurt locally authoritative actors within the radius. Will only hit components that block the Visibility channel.* @param BaseDamage - The base damage to apply, i.e. the damage at the origin.* @param Origin - Epicenter of the damage area.* @param DamageInnerRadius - Radius of the full damage area, from Origin* @param DamageOuterRadius - Radius of the minimum damage area, from Origin* @param DamageFalloff - Falloff exponent of damage from DamageInnerRadius to DamageOuterRadius* @param DamageTypeClass - Class that describes the damage that was done.* @param DamageCauser - Actor that actually caused the damage (e.g. the grenade that exploded)* @param InstigatedByController - Controller that was responsible for causing this damage (e.g. player who threw the grenade)* @param bFullDamage - if true, damage not scaled based on distance from Origin* @param DamagePreventionChannel - Damage will not be applied to victim if there is something between the origin and the victim which blocks traces on this channel* @return true if damage was applied to at least one actor.*/UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category="Game|Damage", meta=(WorldContext="WorldContextObject", AutoCreateRefTerm="IgnoreActors"))static bool ApplyRadialDamageWithFalloff(const UObject* WorldContextObject, float BaseDamage, float MinimumDamage, const FVector& Origin, float DamageInnerRadius, float DamageOuterRadius, float DamageFalloff, TSubclassOf<class UDamageType> DamageTypeClass, const TArray<AActor*>& IgnoreActors, AActor* DamageCauser = NULL, AController* InstigatedByController = NULL, ECollisionChannel DamagePreventionChannel = ECC_Visibility);

cpp实现

bool UGameplayStatics::ApplyRadialDamage(const UObject* WorldContextObject, float BaseDamage, const FVector& Origin, float DamageRadius, TSubclassOf<UDamageType> DamageTypeClass, const TArray<AActor*>& IgnoreActors, AActor* DamageCauser, AController* InstigatedByController, bool bDoFullDamage, ECollisionChannel DamagePreventionChannel )
{float DamageFalloff = bDoFullDamage ? 0.f : 1.f;return ApplyRadialDamageWithFalloff(WorldContextObject, BaseDamage, 0.f, Origin, 0.f, DamageRadius, DamageFalloff, DamageTypeClass, IgnoreActors, DamageCauser, InstigatedByController, DamagePreventionChannel);
}bool UGameplayStatics::ApplyRadialDamageWithFalloff(const UObject* WorldContextObject, float BaseDamage, float MinimumDamage, const FVector& Origin, float DamageInnerRadius, float DamageOuterRadius, float DamageFalloff, TSubclassOf<class UDamageType> DamageTypeClass, const TArray<AActor*>& IgnoreActors, AActor* DamageCauser, AController* InstigatedByController, ECollisionChannel DamagePreventionChannel)
{FCollisionQueryParams SphereParams(SCENE_QUERY_STAT(ApplyRadialDamage),  false, DamageCauser);SphereParams.AddIgnoredActors(IgnoreActors);// query scene to see what we hitTArray<FOverlapResult> Overlaps;if (UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull)){World->OverlapMultiByObjectType(Overlaps, Origin, FQuat::Identity, FCollisionObjectQueryParams(FCollisionObjectQueryParams::InitType::AllDynamicObjects), FCollisionShape::MakeSphere(DamageOuterRadius), SphereParams);}// collate into per-actor list of hit componentsTMap<AActor*, TArray<FHitResult> > OverlapComponentMap;for (int32 Idx=0; Idx<Overlaps.Num(); ++Idx){FOverlapResult const& Overlap = Overlaps[Idx];AActor* const OverlapActor = Overlap.GetActor();if ( OverlapActor && OverlapActor->bCanBeDamaged && OverlapActor != DamageCauser &&Overlap.Component.IsValid() ){FHitResult Hit;if (DamagePreventionChannel == ECC_MAX || ComponentIsDamageableFrom(Overlap.Component.Get(), Origin, DamageCauser, IgnoreActors, DamagePreventionChannel, Hit)){TArray<FHitResult>& HitList = OverlapComponentMap.FindOrAdd(OverlapActor);HitList.Add(Hit);}}}bool bAppliedDamage = false;if (OverlapComponentMap.Num() > 0){// make sure we have a good damage typeTSubclassOf<UDamageType> const ValidDamageTypeClass = DamageTypeClass ? DamageTypeClass : TSubclassOf<UDamageType>(UDamageType::StaticClass());FRadialDamageEvent DmgEvent;DmgEvent.DamageTypeClass = ValidDamageTypeClass;DmgEvent.Origin = Origin;DmgEvent.Params = FRadialDamageParams(BaseDamage, MinimumDamage, DamageInnerRadius, DamageOuterRadius, DamageFalloff);// call damage function on each affected actorsfor (TMap<AActor*, TArray<FHitResult> >::TIterator It(OverlapComponentMap); It; ++It){AActor* const Victim = It.Key();TArray<FHitResult> const& ComponentHits = It.Value();DmgEvent.ComponentHits = ComponentHits;Victim->TakeDamage(BaseDamage, DmgEvent, InstigatedByController, DamageCauser);bAppliedDamage = true;}}return bAppliedDamage;
}

2.Apply Radial Damage with Falloff (falloff为0不衰减,越大衰减越快

第六章 射线检测

1零粗细(很细)射线检测

射线通道TraceChannel

Visibility——适用于两点之间,存在障碍物时触发

Camera——适用于从相机发出射线

TraceComplex——针对复杂物体,检测复杂碰撞体还是简单的碰撞体,一般不开启

Note设置Start End Position

绘制射线的持续时间

2零检测返回结果

法线

测试

4球体非零粗细检测

5调试检测结果

蓝图

预测

实际

6多重零粗细检测

1.立方体 碰撞预设设置由BlockAll变为OverlapAll

Blocking Hit 绿色为false,红色为true

7盒子、胶囊体检测

Orientation——方向

8逐多边形检测

Trace Complex 不勾选——检测碰撞体

勾选——检测多边形模型

同时,模型选择Use Complex Collision As Simple Collision

【学习笔记】Unreal Engine 4 虚幻引擎蓝图中级教程物理碰撞教程相关推荐

  1. Unreal Engine(虚幻引擎)渲染 – 正确使用方法

    我们已经讨论过 Unreal Engine(虚幻引擎)中可用的很多神奇工具,包括最近抢先体验的 Unreal Engine 5.多亏了 Epic,世界各地的开发人员和团队都可以轻松进行游戏开发.Epi ...

  2. ue4 曲线图实现 蓝图_UE4虚幻引擎蓝图制作自动开关门(超详细图文教程

    原标题:UE4虚幻引擎蓝图制作自动开关门(超详细图文教程 自己花费了一天多的时间来编写和整理这篇图文教程,相信看了后能轻松学会使用蓝图制作会自动开关的单开门的,大家可以举一反三,尝试使用蓝图制做双开关 ...

  3. node.js 学习笔记(二)模板引擎和C/S渲染

    node.js 学习笔记(二)模板引擎和C/S渲染 文章目录 node.js 学习笔记(二)模板引擎和C/S渲染 一.初步实现Apache功能 1.1 使用模板引擎 1.2 在 node 中使用模板引 ...

  4. 《从C语言过渡到C++和虚幻引擎中的C++编程》教程①

    本系列文字教程的受众对象是刚刚经历完大一上的C语言期末考试的.仅具有一定C语言基础的新生. 如果您是上述对象,在看完本系列教程之后,您将收获C++编程入门和虚幻引擎中的C++编程入门知识以及一些游戏开 ...

  5. HaaS学习笔记 | 基于HaaS Python轻应用的LED跑马灯明细教程

    [1]题目要求     [案例]:在HaaS框架下实现LED跑马灯.       蓝蜻蜓ESP32开发板的LED灯电路连接如下:       D3灯----GPIO14,高电平点亮,低电平熄灭.   ...

  6. “2018 Unreal Open Day 虚幻引擎技术开放日”活动开启预售

    "UnrealOpen Day虚幻引擎技术开放日"(下文简称UnrealOpen Day) 是由EpicGames中国倾力打造的面向虚幻引擎开发者的技术分享活动. 作为引擎行业规格 ...

  7. 【Rider for Unreal Engine】虚幻4如何进行项目管理 Git 操作总结

    前言 虚幻4自带了项目管理,使用起来非常的便捷和舒服. 对于新手唯一的难处就在于记住命令,不过没有关系,用多了就好了,刚开始肯定会忘记命令的,所以建议将本文章收藏,不记得命令的时候直接点开查看即可,省 ...

  8. CSGO UE4 -CSGO地图导入Unreal Engine 4虚幻4

    准备工具 软件:Unreal Engine 4,GCFScape,bspsrc,HammUEr插件 其他东西的教程,比如如何反编译模型之类的,其他教程已经写出,这里就不重复了 反编译CSGO地图 这里 ...

  9. MySQL学习笔记(二):MyISAM 存储引擎

    MyISAM 存储引擎 MyISAM 基于旧的 (不再可用) ISAM 存储引擎, 但有许多有用的扩展. 每个 MyISAM 表都存储在三个文件中的磁盘上.这些文件具有以表名开头的名称, 并具有用于指 ...

最新文章

  1. @slf4j注解_SpringBoot + Redis + 注解 + 拦截器 实现接口幂等性校验
  2. FD_ISSET read 后程序被阻塞【原创】
  3. 小小智慧树机器人_中国工厂番外篇丨AGV机器人演绎智能“搬运工”
  4. Linux 中如何启用和禁用网卡?
  5. 2020_1123_生活记录
  6. centos7使用kubeadm部署高可用k8s集群
  7. robotframework-接口测试详解(上传文件)
  8. vscode如何使用ajax,Ajax 的初步实现(使用vscode+node.js+express框架)
  9. ipd敏捷开发_融入华为IPD软件开发流程与敏捷开发实施java课程设计
  10. HBuilder如何运行到MuMu模拟器教程
  11. sqlite3命令行基本操作
  12. Windows 10 输入法莫名其妙变为繁体的解决方法
  13. 常用软件过程模型-快速原型模型,快速原型模型有哪几种?各有何特点?
  14. python之调用科大讯飞的语音合成
  15. Nonebot QQ机器人插件八:点歌(网易云音乐)
  16. block locality
  17. 在图书馆看到自己出版的图书是一种怎样的体验?
  18. Excel在统计分析中的应用—第二章—描述性统计-分组数据的中位数的求解方法(组离散数据)
  19. Eclipse Memory Analyzer 的使用教程最实用
  20. Linux(一)之相关介绍与安装

热门文章

  1. R型低频变压器和高频变压器有什么不一样?
  2. 我的FOXBASE旅程 (转)
  3. [IINA排错 | 已解决] 播放视频声音变为杂音
  4. 模拟不稳定的网络状况的软件clumsy
  5. Wireshark下载安装
  6. 20年后的iphoneXXXX手机长这样
  7. HyperMesh生成Flac3D的剖分网格
  8. shodan python
  9. Unity隐藏或显示鼠标
  10. dna分子结构具有抽象_新技术活动,抽象是具有远见的