UE4学习笔记16th
来源:互联网 发布:抓鬼软件 编辑:程序博客网 时间:2024/05/16 05:47
这一节对PawnMovementComponent进行编辑,确定响应。
首先打开PawnMovementComponent.h添加如下代码:
在PawnMovementComponent.cpp中定义它:
ConsumeInputVector(),获取移动向量
SafeMoveUpdatedComponent,处理移动
SlideAlongSurface,处理阻挡
首先打开PawnMovementComponent.h添加如下代码:
public:
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
在PawnMovementComponent.cpp中定义它:
//Make sure that everything is still valid, and that we are allowed to move.
if (!PawnOwner || !UpdatedComponent || ShouldSkipUpdate(DeltaTime))
{
return;
}//
//Get (and then clear) the movement vector that we set in ACollidingPawn::Tick
FVector DesiredMovementThisFrame = ConsumeInputVector().GetClampedToMaxSize(1.0f) * DeltaTime * 150.0f;
if (!DesiredMovementThisFrame.IsNearlyZero())
{
FHitResult Hit;
SafeMoveUpdatedComponent(DesiredMovementThisFrame, UpdatedComponent->GetComponentRotation(), true, Hit);
//If we bumped into something, try to slide along it
if (Hit.IsValidBlockingHit())
{
SlideAlongSurface(DesiredMovementThisFrame, 1.f - Hit.Time,Hit.Normal,Hit);
}
}
ConsumeInputVector(),获取移动向量
SafeMoveUpdatedComponent,处理移动
SlideAlongSurface,处理阻挡
0 0
- UE4学习笔记16th
- UE4学习笔记16th:编辑PawnMovementComponent
- UE4学习笔记4th
- UE4学习笔记5th
- UE4学习笔记6th
- UE4学习笔记7th
- UE4学习笔记8th
- UE4学习笔记9th
- UE4学习笔记10th
- UE4学习笔记11th
- UE4学习笔记12th
- UE4学习笔记13th
- UE4学习笔记14th
- UE4学习笔记15th
- UE4学习笔记17th
- UE4学习笔记18th
- UE4学习笔记19th
- UE4学习笔记20th
- Google性能工程师Ilya Grigorik谈HTTP2
- 网页 布局响应式设计
- 南邮 OJ 1250 最优合并问题
- Waited long enough for: ServiceRecord 问题解决
- mysql 安装配置的问题
- UE4学习笔记16th
- OpenGL超级宝典visual studio 2013开发环境配置,GLTools
- 关键字explicit
- rose初始化
- HDU 2544 最短路(四种写法:Floyd、Dijkstra、Bellman-Ford、SPFA)
- 修改MySQL字符编码【Linux】
- springMVC的搭建
- Android Api Demos登顶之路(二十)Screen Orientation
- 南邮 OJ 1253 程序存储问题