force | 世界坐标系中的力向量。 |
position | 世界坐标系中的一个位置。 |
mode | 要应用的力的类型。 |
在特定position
处应用force
,从而对物体施加扭矩和力。
为了获得逼真的效果,position
应大致位于关节体的表面范围内。这非常适合模拟爆炸。要创建逼真的爆炸,请在多个帧而不是只在一帧中应用力。请注意,当position
远离关节体的中心时,施加的扭矩将变得不切实际地大。
您只能对活动的关节体应用力。如果游戏对象处于非活动状态,AddForceAtPosition 不会产生任何效果。
ForceMode.Force 模式修改每秒线性速度和每秒角速度累加器,而ForceMode.Impulse 模式修改每步线性速度和每步角速度累加器。混合这两种力模式对关节体无效,只会导致应用线性速度累加器。
有关 ForceMode 如何影响速度的更多信息,请参阅Rigidbody.AddForce.
对关节体应用力将使该关节体唤醒。如果力的大小为零,则关节体不会唤醒。
测量单位 - N(牛顿)。
此方法不支持ForceMode.Acceleration和ForceMode.VelocityChange。
其他资源:AddForce、AddRelativeForce、AddTorque.
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { void ApplyForce(ArticulationBody body) { Vector3 direction = body.transform.position - transform.position; body.AddForceAtPosition(direction.normalized, transform.position); } }
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.