【问题标题】:How can i throw an object to a specific point with physics我怎样才能用物理学把一个物体扔到一个特定的点
【发布时间】:2022-01-20 21:04:33
【问题描述】:

我正是想要这个:

上篮的概率一定是100%。

Throw

我试过这个:

Vector3 direction = new Vector3(pota.position.x - transform.position.x, pota.position.y - transform.position.y, pota.position.z - transform.position.z);
float vAngle = Vector3.Angle(direction, Vector3.forward);
float hAngle = Vector3.Angle(direction, Vector3.left);
float distance = Vector3.Distance(transform.position, pota.position);
float yDistance = Mathf.Abs(distance * Mathf.Cos(vAngle)) + 0.5f;
float xzDistance = (distance * Mathf.Sin(vAngle));
float xDistance = (xzDistance * Mathf.Sin(hAngle));
float zDistance = Mathf.Abs(xzDistance * Mathf.Cos(hAngle));                    
rb.AddForce(new Vector3(xDistance, yDistance, zDistance), ForceMode.Impulse);

感谢您的帮助。

【问题讨论】:

    标签: unity3d physics throw


    【解决方案1】:

    这是一件非常复杂的事情,没有真正简单的方法来解决这个问题

    阅读此问题中的一个答案 祝你好运 https://math.stackexchange.com/questions/3486775/how-do-you-calculate-the-trajectory-of-an-arrow

    (或者你可以只使用 lurp 或 slurp 或 movetowards lel)

    【讨论】:

    • 感谢您的帮助
    • @absakalli np mate
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 2020-07-17
    • 1970-01-01
    • 1970-01-01
    • 2023-01-26
    相关资源
    最近更新 更多