UE4 SetPhysicsLinearVelocity、AddForce区别 - 纳金网
联系我们

给我们留言

联系我们

地址:福建省晋江市青阳街道洪山路国际工业设计园纳金网

邮箱:info@narkii.com

电话:0595-82682267

(周一到周五, 周六周日休息)

当前位置:主页 > 3D教程 > 图文教程

UE4 SetPhysicsLinearVelocity、AddForce区别

来源: 52vr | 责任编辑:传说的落叶 | 发布时间: 2019-06-06 08:19 | 浏览量:

[UE4]SetPhysicsLinearVelocity、AddForce区别

 

SetPhysicsAngularVelocity:用于旋转物体。但官方文档建议谨慎使用此接口,建议用 AddTorque或者AddImpulse

 

AddForce用法:

 
  1. mesh->AddForce(FVector::RightVector * mesh->GetBodyInstance()->GetBodyMass() * 1000);  

https://answers.unrealengine.com/questions/290824/addforceaddimpulse-wont-work.html

 

修改Velocity:
一般动画蓝图中使用Velocity来判定当前对象的移动速度从而来判定是否播放跑步动画。AddForce并不会修改Velocity值,所以如果要移动的同时来设置Velocity,需要手动设置:

 
  1. MyChar->GetCharacterMovement()->Velocity += FVector(0,0,20000);  

https://answers.unrealengine.com/questions/27069/addimpulse-or-addforce-on-character.html

 

 

注意,如果要使用SetPhysicsLinearVelocity(),需要将SetSimulatePhysics设置为true

 
  1. MyCharacter->GetMesh()->SetSimulatePhysics(true);  
  2. MyCharacter->GetMesh()->SetPhysicsLinearVelocity(FVector(100.f, 100.f, 100.f));  

 https://answers.unrealengine.com/questions/140978/how-to-set-a-initial-velocity.html

 

 

UPrimitiveComponent::AddForce
https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Components/UPrimitiveComponent/AddForce/index.html

 

UPrimitiveComponent::AddImpulse

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Components/UPrimitiveComponent/AddImpulse/index.html

 

UPrimitiveComponent::SetPhysicsLinearVelocity

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Components/UPrimitiveComponent/SetPhysicsLinearVelocity/index.html

 

UPrimitiveComponent::SetPhysicsAngularVelocity
https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Components/UPrimitiveComponent/SetPhysicsAngularVelocity/index.html


相关文章
网友评论

您需要登录后才可以发帖 登录 | 立即注册

关闭

全部评论:0条

推荐
热门