Improved the drift correction on the NetworkedNavMeshAgent
This commit is contained in:
parent
7338299ff2
commit
c46f268470
@ -11,6 +11,9 @@ namespace MLAPI.MonoBehaviours.Prototyping
|
|||||||
public bool EnableProximity = false;
|
public bool EnableProximity = false;
|
||||||
public float ProximityRange = 50f;
|
public float ProximityRange = 50f;
|
||||||
public float CorrectionDelay = 3f;
|
public float CorrectionDelay = 3f;
|
||||||
|
//TODO rephrase.
|
||||||
|
[Tooltip("Everytime a correction packet is recieved. This is the percentage (between 0 & 1) that we will move towards the goal.")]
|
||||||
|
public float DriftCorrectionPercentage = 0.1f;
|
||||||
|
|
||||||
private static byte[] stateUpdateBuffer = new byte[36];
|
private static byte[] stateUpdateBuffer = new byte[36];
|
||||||
private static byte[] correctionBuffer = new byte[24];
|
private static byte[] correctionBuffer = new byte[24];
|
||||||
@ -153,7 +156,7 @@ namespace MLAPI.MonoBehaviours.Prototyping
|
|||||||
Vector3 position = new Vector3(xPos, yPos, zPos);
|
Vector3 position = new Vector3(xPos, yPos, zPos);
|
||||||
|
|
||||||
agent.velocity = velocity;
|
agent.velocity = velocity;
|
||||||
agent.Warp(position);
|
agent.Warp(Vector3.Lerp(transform.position, position, DriftCorrectionPercentage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user