UE4设置MovementMode
UE4内置了一些行为模式,比如:Walking、Flying等,这两种是UE4提供的现成的移动模式,使用Walking移动对象会受重力影响,如果是用Flying不受重力影响,只有设置为Flying模式,就不需要你写代码来考虑重力的问题。
也可以自定义移动模式,比如:项目中有两个状态,行走和爬梯子,爬梯子是一个复杂的动画逻辑,切换到爬梯子动画时需要设置一系列数据,那么可以将这些设置操作定义为一种MovementMode,然后每次切换时只需要一行代码,相当于封装成一个函数。
蓝图方式
在Character蓝图中:Character Movement -》 Set Movement Mode
C++方式
- MyCharacter->GetCharacterMovement()->SetMovementMode(EMovementMode::MOVE_Flying);
其他参考:
UCharacterMovementComponent::SetMovementMode
https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/UCharacterMovementComponent/SetMovementMode/index.html
How to make blueprints can swith to flying mode
https://answers.unrealengine.com/questions/88390/how-to-make-blueprints-can-swith-to-flying-mode.html
Blueprint Creating Custom Character Movement Component
https://wiki.unrealengine.com/Blueprint_Creating_Custom_Character_Movement_Component
全部评论:0条