mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交
This commit is contained in:
@@ -23,7 +23,7 @@ namespace Pathfinding.RVO {
|
||||
/// // Calculate how much to move during this frame
|
||||
/// // This information is based on movement commands from earlier frames
|
||||
/// // as local avoidance is calculated globally at regular intervals by the RVOSimulator component
|
||||
/// var delta = controller.CalculateMovementDelta(transform.position, Time.deltaTime);
|
||||
/// var delta = controller.CalculateMovementDelta(transform.position, GetSync().Time.deltaTime);
|
||||
/// transform.position = transform.position + delta;
|
||||
/// }
|
||||
/// </code>
|
||||
@@ -264,10 +264,10 @@ namespace Pathfinding.RVO {
|
||||
/// </summary>
|
||||
public Vector3 velocity {
|
||||
get {
|
||||
// For best accuracy and to allow other code to do things like Move(agent.velocity * Time.deltaTime)
|
||||
// For best accuracy and to allow other code to do things like Move(agent.velocity * GetSync().Time.deltaTime)
|
||||
// the code bases the velocity on how far the agent should move during this frame.
|
||||
// Unless the game is paused (timescale is zero) then just use a very small dt.
|
||||
var dt = Time.deltaTime > 0.0001f ? Time.deltaTime : 0.02f;
|
||||
var dt = GetSync().Time.deltaTime > 0.0001f ? GetSync().Time.deltaTime : 0.02f;
|
||||
return CalculateMovementDelta(dt) / dt;
|
||||
}
|
||||
set {
|
||||
@@ -281,7 +281,7 @@ namespace Pathfinding.RVO {
|
||||
/// The position of the agent is taken from the attached movement script's position (see <see cref="Pathfinding.IAstarAI.position)"/> or if none is attached then transform.position.
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">How far to move [seconds].
|
||||
/// Usually set to Time.deltaTime.</param>
|
||||
/// Usually set to GetSync().Time.deltaTime.</param>
|
||||
public Vector3 CalculateMovementDelta (float deltaTime) {
|
||||
if (rvoAgent == null) return Vector3.zero;
|
||||
return To3D(Vector2.ClampMagnitude(rvoAgent.CalculatedTargetPoint - To2D(ai != null ? ai.position : tr.position), rvoAgent.CalculatedSpeed * deltaTime), 0);
|
||||
@@ -308,7 +308,7 @@ namespace Pathfinding.RVO {
|
||||
/// </summary>
|
||||
/// <param name="position">Position of the agent.</param>
|
||||
/// <param name="deltaTime">How far to move [seconds].
|
||||
/// Usually set to Time.deltaTime.</param>
|
||||
/// Usually set to GetSync().Time.deltaTime.</param>
|
||||
public Vector3 CalculateMovementDelta (Vector3 position, float deltaTime) {
|
||||
return To3D(Vector2.ClampMagnitude(rvoAgent.CalculatedTargetPoint - To2D(position), rvoAgent.CalculatedSpeed * deltaTime), 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user