计算特定点unity3d处的物体的局部速度

时间:2016-12-01 09:34:42

标签: c# unity3d scripting physics game-physics

我正在尝试创建自定义车辆物理系统,而不使用内置的车轮碰撞器。

我有一个立方体(刚体),有4个点作为悬挂点(车轮位置点)。我想计算这些点沿其局部x轴的速度,以便我可以向刚体施加侧向摩擦力,以阻止它向侧面移动。

// previousSuspensionPoint (Transform) is a global variable in the script
// that holds the previous position of the suspension point
//
// suspensionPoint (Transform) is the current position of the suspension point

// If the position of the suspension point changes, calculate the velocity of that point
if (previousSuspensionPoint.position.x != suspensionPoints.position.x)
{
    // Calculating the velocity of the point
    sidewaysVelocity = (previousSuspensionPoint.position.x - suspensionPoints.position.x) / Time.fixedDeltaTime;
    Debug.Log("sideWayVelocity: " + sidewaysVelocityFront[i]);

    previousSuspensionPoint = suspensionPoints;
}

此代码根据全局轴计算速度。我想在点的局部轴上计算

0 个答案:

没有答案