【问题标题】:Unity3D configurable joint troubleunity3D 可配置关节故障
【发布时间】:2018-11-02 14:33:07
【问题描述】:

我需要设置像铰链关节这样的可配置关节,它应该像金属梁一样将玩家与物体连接起来,但问题是当我设置锚点并限制它向前飞到的轴时玩家不会立即停止物体然后下降到极限,所以我的光束将他的尺寸从短变长,这很糟糕。你能帮帮我吗?

这里是代码sn-p:

playerJoint.connectedAnchor = anchor.transform.position;
SoftJointLimit limit = new SoftJointLimit();
limit.limit = Vector3.Distance(anchor.transform.position, transform.position);
playerJoint.linearLimit = limit;
playerJoint.yMotion = ConfigurableJointMotion.Limited;
playerJoint.xMotion = ConfigurableJointMotion.Limited;

然后当玩家松开按钮时,会运行以下代码:

playerJoint.yMotion = ConfigurableJointMotion.Free;
playerJoint.xMotion = ConfigurableJointMotion.Free;

提前谢谢你。

【问题讨论】:

    标签: c# unity3d game-physics


    【解决方案1】:

    这听起来很像Rigidbody.interpolation 问题。

    如果不是,您应该尝试手动将播放器的位置更改为您想要的长度。比如:

    Vector3 hinge2Player = player.transform.position - anchor.transform.position;
    hinge2Player = Vector3.ClampMagnitude(hinge2Player, /* [distance you want] */);
    player.transform.position = hinge2Player + anchor.transform.position;
    

    this 也很有可能会有所帮助,因为您似乎正在尝试做类似的事情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-05
      • 1970-01-01
      • 2011-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多