UE4 SetPhysicsLinearVelocity、AddForce區(qū)別
SetPhysicsAngularVelocity:用于旋轉(zhuǎn)物體。但官方文檔建議謹(jǐn)慎使用此接口,建議用 AddTorque或者AddImpulse
AddForce用法:
- mesh->AddForce(FVector::RightVector * mesh->GetBodyInstance()->GetBodyMass() * 1000);
https://answers.unrealengine.com/questions/290824/addforceaddimpulse-wont-work.html
修改Velocity:
一般動畫藍(lán)圖中使用Velocity來判定當(dāng)前對象的移動速度從而來判定是否播放跑步動畫。AddForce并不會修改Velocity值,所以如果要移動的同時(shí)來設(shè)置Velocity,需要手動設(shè)置:
- MyChar->GetCharacterMovement()->Velocity += FVector(0,0,20000);
https://answers.unrealengine.com/questions/27069/addimpulse-or-addforce-on-character.html
注意,如果要使用SetPhysicsLinearVelocity(),需要將SetSimulatePhysics設(shè)置為true:
- MyCharacter->GetMesh()->SetSimulatePhysics(true);
- 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
-
分享到:
您需要登錄后才可以發(fā)帖 登錄 | 立即注冊
- 用戶名:
- 密 碼:
- 驗(yàn)證碼: 看不清? 點(diǎn)擊更換
- 忘記密碼?
全部評論:0條