UE4之SetRelativeLocation 和SetRelativeRotation

参考:

https://docs.unrealengine.com/en-US/BlueprintAPI/Utilities/Transformation/SetRelativeLocation/index.html

 

SetRelativeLocation :设置组件相对于父组件的位置

参数为

FVector

我这里主要举个例子在说明这个函数的意思,比较直观

调用如下函数:

MSkeletaMeshComponent->SetRelativeLocation(FVector(0,0,-90));

显示效果:

UE4之SetRelativeLocation 和SetRelativeRotation_第1张图片

 MSkeletaMeshComponent->SetRelativeLocation(FVector(0,0,-160));

UE4之SetRelativeLocation 和SetRelativeRotation_第2张图片

 MSkeletaMeshComponent->SetRelativeLocation(FVector(0,90,-90));

UE4之SetRelativeLocation 和SetRelativeRotation_第3张图片

 MSkeletaMeshComponent->SetRelativeLocation(FVector(90,0,-90));

UE4之SetRelativeLocation 和SetRelativeRotation_第4张图片

 总结:

改变x的值,人物朝着前后移动

改变y的值,人物朝着左右移动

改变z的值,人物上下移动

这里是坐标,基本上可以对应上。

UE4之SetRelativeLocation 和SetRelativeRotation_第5张图片

 

SetRelativeRotation:这个函数主要设置人物的旋转

MSkeletaMeshComponent->SetRelativeRotation(FRotator(0, -90, 0));

UE4之SetRelativeLocation 和SetRelativeRotation_第6张图片

MSkeletaMeshComponent->SetRelativeRotation(FRotator(0, -45, 0));

UE4之SetRelativeLocation 和SetRelativeRotation_第7张图片

 MSkeletaMeshComponent->SetRelativeRotation(FRotator(45, -90 ,0));

UE4之SetRelativeLocation 和SetRelativeRotation_第8张图片

 MSkeletaMeshComponent->SetRelativeRotation(FRotator(0, -90 ,45));

UE4之SetRelativeLocation 和SetRelativeRotation_第9张图片

 看一下定义解释

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;

你可能感兴趣的:(UE4)