上个博客解决了相机和人物方向相同的问题。接下来学习怎么使用代码实现。
在虚幻引擎文档中找到我们需要包含的文件
#include "GameFramework/CharacterMovementComponent.h"
将头文件包含在里面。
GetCharacterMovement()->bOrientRotationToMovement = true;
GetCharacterMovement()->RotationRate = FRotator(0.f, 300.f, 0.f);
把bOrientRotationToMovement设定为true。
RotationRate用来设定旋转速度。