x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

上半身随镜头旋转时发生了一个错误:

嗨, 你们好. 我在使用Transform(Modify) Bone 函数的时候出现了一个很奇怪的问题: 未控制的角色姿势很奇异, 并且只会在第一次启动编辑器并且点击Play时出现, Play几次后就没有这个问题了. 就是这样: alt text https://drive.google.com/open?id=1Ow9xhnjvE3G9e8CxWSE8cFFN83GTsJK8

首先我在Animation Instance BP里面定义了TurnBody方法, 然后再每次刷新动画的时候调用他, 计算身体和头部应该面向哪个地方(BodyRotation), 如下图: alt text https://drive.google.com/open?id=1FfngKtp_fScKH8sZVwGqwbMLeBoyvLCO

PitchAjuster(后改为RotationAjuster)这个变量用于防止BodyRotation不再改变(当镜头不再改变的时候, BodyRotation就不会发生改变), 这时会导致另外一个很奇怪的问题: 当我控制的角色靠近其他的可碰撞物体, 如远处的那头熊, 旁边的墙且BodyRotation不再改变的时候, 就会出现奇异的姿势. 然后我尝试在我的动画视图中调用Transform(Modify) Bone方法, 将我的上半身旋转与状态机动画混合, 如下图: alt text https://drive.google.com/open?id=1EyWTZKQ3f8BhRlm7DUg27TjuqjkFSNGz

我刚开始学习UE4, 老实说我不知道这个是不是一个Bug, 非常感谢你们的帮助!

Product Version: UE 4.17
Tags:
more ▼

asked Sep 08 '18 at 02:59 AM in Chinese

avatar image

SimplestWay
10 3 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

好吧, 我承认UE4里面有些很不容易理解的大坑, 比如说GetControlRotation()返回的是0-360的角度, 而GetActorRotation()返回的是介于-180~180的角度, 当两者相减时, 就会导致可能出现-560 ~ 560之间的角度, 导致人物变成麻花状(为什么只在有控制器的情况下出现在这种情况我现在仍然不是太明白). 总之我现在已经不再使用蓝图来实现我的大部分逻辑了, 使用C++会更方面调试和修改, 经过一段时间的努力后, 代码变得很简单, 如果任何人想实现类似的功能, 你可以直接复制一下代码:

 FRotator YourUtilClass::GetUpperBodyRotation(class ACharacter* InCharacter, FRotator CurrentBodyRotation)
 {
     if (!InCharacter) {
         return FRotator(0.0F);
     }
 
     FRotator PawnRot = InCharacter->GetActorRotation();
     FRotator CtrlRot = InCharacter->GetControlRotation();
 
     FRotator NewBodyRot = PawnRot - CtrlRot;
     NewBodyRot.Normalize();
     float DeltaSecond = InCharacter->GetWorld()->GetDeltaSeconds();
     NewBodyRot = FMath::RInterpTo(CurrentBodyRotation, NewBodyRot, DeltaSecond, 6);
     return NewBodyRot;
 }

Normalize()方法确保在不同范围的Rotator相减后仍然保持正确的范围.

more ▼

answered Nov 01 '18 at 01:05 PM

avatar image

SimplestWay
10 3 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question