统一拉绳子

发布于 2025-02-12 04:15:21 字数 207 浏览 1 评论 0原文

如何在Mudrunner中创建一个绞车系统来拉动物体? 还是用绳索拉其他车辆或刚性物体? 我在Mudrunner Winch系统中看到了,我对如何使其团结一致非常感兴趣。您可以将自己拉到物体上或拉动被卡住的车辆 示例

How can I create a winch system like in Mudrunner, to pull objects?
Or to pull other vehicle or rigidbody object with rope?
I saw in mudrunner winch system and I am very interested on how to make it in unity. You can pull yourself to objects or to pull vehicles that are stuck
example

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苄①跕圉湢 2025-02-19 04:15:21

如果我正确理解,当您拉一个对象时,您希望其方向保持相同,但它的距离与固定物体的距离降低。

对于GameObjects“目标”和“枢轴”,需要将“目标”朝向“枢轴”,可以使用以下方向“目标”移动:

Vector3 pullDirection = (pivot.transform.position - target.transform.position).normalized

朝这个方向移动目标会将其拉向枢。您可以使用以下任何方法将其移动,其中RB是目标的刚性体:

rb.AddForce(pullDirection * forceStrength)
rb.MovePosition(target.transform.position + (pullDirection * pullSpeed))

将Plldldirection或Pullspeed设置为您认为最适合游戏的任何方法。

If I understand correctly, when you pull an object, you want the direction of it to remain the same but the distance of it to the stationary object to decrease.

In the case of GameObjects "target" and "pivot" where "target" needs to be pulled towards "pivot", the direction "target" needs to move can be found using this:

Vector3 pullDirection = (pivot.transform.position - target.transform.position).normalized

Moving the target in this direction would pull it towards the pivot. You can use any of the following methods to move it, where rb is the target's rigidbody:

rb.AddForce(pullDirection * forceStrength)
rb.MovePosition(target.transform.position + (pullDirection * pullSpeed))

Set pullDirection or pullSpeed to whatever you think will work best for your game.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文