参考:
https://docs.unrealengine.com/en-US/BlueprintAPI/Utilities/Transformation/SetRelativeLocation/index.html
SetRelativeLocation :设置组件相对于父组件的位置
参数为
FVector
我这里主要举个例子在说明这个函数的意思,比较直观
调用如下函数:
MSkeletaMeshComponent->SetRelativeLocation(FVector(0,0,-90));
显示效果:
MSkeletaMeshComponent->SetRelativeLocation(FVector(0,0,-160));
MSkeletaMeshComponent->SetRelativeLocation(FVector(0,90,-90));
MSkeletaMeshComponent->SetRelativeLocation(FVector(90,0,-90));
总结:
改变x的值,人物朝着前后移动
改变y的值,人物朝着左右移动
改变z的值,人物上下移动
这里是坐标,基本上可以对应上。
SetRelativeRotation:这个函数主要设置人物的旋转
MSkeletaMeshComponent->SetRelativeRotation(FRotator(0, -90, 0));
MSkeletaMeshComponent->SetRelativeRotation(FRotator(0, -45, 0));
MSkeletaMeshComponent->SetRelativeRotation(FRotator(45, -90 ,0));
MSkeletaMeshComponent->SetRelativeRotation(FRotator(0, -90 ,45));
看一下定义解释
struct FRotator
{
public:
/** Rotation around the right axis (around Y axis), Looking up and down (0=Straight Ahead, +Up, -Down) */
float Pitch;
/** Rotation around the up axis (around Z axis), Running in circles 0=East, +North, -South. */
float Yaw;
/** Rotation around the forward axis (around X axis), Tilting your head, 0=Straight, +Clockwise, -CCW. */
float Roll;