UE4之SetRelativeLocation 和SetRelativeRotation

参考:

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;

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值