转向行为速度过快

我正尝试在我的 XNA 游戏中实现转向行为,大部分功能都已经实现,但有些小问题需要帮助。 这些行为本身工作良好,问题在于更新的时机和幅度。

(我正在使用 SharpSteer (目前几乎完全使用),可以在这里找到它:

http://sharpsteer.codeplex.com/SourceControl/changeset/view/18102)

我正在努力解决 Update() 方法。 目前我正在使用这个方法(直接来自 SharpSteer):

    // apply a given steering force to our momentum,    // adjusting our orientation to maintain velocity-alignment.    public void ApplySteeringForce(Vector3 force, float elapsedTime)    {        Vector3 adjustedForce = AdjustRawSteeringForce(force, elapsedTime);        // enforce limit on magnitude of steering force        Vector3 clippedForce = Vector3Helpers.TruncateLength(adjustedForce, MaxForce);        // compute acceleration and velocity        Vector3 newAcceleration = (clippedForce / Mass);        Vector3 newVelocity = Velocity;        // damp out abrupt changes and oscillations in steering acceleration        // (rate is proportional to time step, then clipped into useful range)        if (elapsedTime > 0)        {            float smoothRate = Utilities.Clip(9 * elapsedTime, 0.15f, 0.4f);            Utilities.BlendIntoAccumulator(smoothRate, newAcceleration, ref acceleration);        }        // Euler integrate (per frame) acceleration into velocity        newVelocity += acceleration * elapsedTime;        // enforce speed limit        newVelocity = Vector3Helpers.TruncateLength(newVelocity, MaxSpeed);        // update Speed        Speed = (newVelocity.Length());        // Euler integrate (per frame) velocity into position        Position = (Position + (newVelocity * elapsedTime));        // regenerate local space (by default: align vehicle's forward axis with        // new velocity, but this behavior may be overridden by derived classes.)        RegenerateLocalSpace(newVelocity, elapsedTime);        // maintain path curvature information        MeasurePathCurvature(elapsedTime);        // running average of recent positions        Utilities.BlendIntoAccumulator(elapsedTime * 0.06f, // QQQ                              Position,                              ref smoothedPosition);    }

这可以工作,但由于 elapsed time 乘数,帧与帧之间的变化非常大(我认为 SharpSteer 使用的是它自己的游戏时钟,而不是 gameTime,我正在使用 gameTime)。

我正在寻找一种方法来大幅减慢速度,并在大于 1.0f 的范围内使用速度值。

目前我使用的速度为 1.0f,最大力为 1.0f。 我注意到 Velocity 总是 (0,0,0),elapsedTime 是 16(这每秒调用 60 次),smoothRate 总是 0.4f,这也是因为 elapsedTime 太大了。

如果有人能帮我稍微平衡一下车辆的速度,我将不胜感激。


回答:

增加质量将抑制(减慢)加速度,对于进入该方法的相同大小的力。 你确定你设置了合适的质量值吗?

此外,你的速度是否代表单位/秒? 如果是这样,那么 16 毫秒的经过时间应该是 0.016;

Related Posts

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注