2D点力场将力应用于吸引/排斥源点,该源点可以是刚体的位置或力场使用的碰撞器的中心。当另一个(目标)碰撞器与力场接触时,则对目标应用力。可以控制施加力的位置和计算方法。
与力场一起使用的碰撞器通常会设置为触发器,以便其他碰撞器可以与之重叠以施加力,但非触发器仍然有效,但只有在碰撞器与之接触时才会施加力。
属性 | 函数 |
---|---|
使用碰撞器遮罩 | 是否应使用“碰撞器遮罩”属性?如果不使用,则全局碰撞当物理引擎检测到两个GameObject的碰撞器接触或重叠时,至少有一个具有Rigidbody组件并且在运动时发生碰撞。 更多信息 在词汇表中查看 矩阵将保持不变,这是所有碰撞器的默认设置。 |
碰撞器遮罩 | 用于选择允许与力场交互的特定层的遮罩。 |
力的大小 | 要应用力的幅度。 |
力变化 | 要应用力幅度的变化。 |
距离缩放 | 应用于源点和目标之间距离的缩放。距离计算时,将按此量缩放,允许有效距离变化,从而控制施加的力的大小。 |
阻力 | 应用于刚体的线性阻力。 |
角阻力 | 应用于刚体的角阻力。 |
力源 | 力源是吸引或排斥目标对象的点。从该点到目标距离的定义。 |
碰撞器用于处理对象物理碰撞的不可见形状。碰撞器不必与对象的网格完全相同 - 通常,粗糙的近似比精确形状更有效且在游戏中不可区分。 更多信息 在词汇表中查看 |
源点定义为当前碰撞器的位置。 |
刚体允许GameObject受到模拟重力和其他力的影响的组件。 更多信息 在词汇表中查看 |
源点定义为当前刚体的位置。 |
力目标 | 力目标是力场施加力的目标对象上的点。从该点到源的距离定义为。 |
碰撞器 | 目标点定义为当前碰撞器的位置。如果碰撞器未位于质心位置,则在此处施加力可以产生扭矩(使目标旋转)。 |
刚体 | 目标点被定义为刚体的当前质心。在此处施加力将永远不会产生扭矩(使目标旋转)。 |
力模式 | 力的计算方式。 |
常数 | 力被施加,忽略源和目标之间的距离。 |
逆线性 | 力被施加为源和目标之间的逆线性距离的函数。当源和目标位于同一位置时,施加全部力量,但随着它们相互远离,力量呈线性衰减。 |
逆平方 | 力被施加为源和目标之间的逆平方距离的函数。当源和目标位于同一位置时,施加全部力量,但随着它们相互远离,力量以平方速率衰减。这与现实世界的重力类似。 |
PointEffector2D
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.