This commit is contained in:
PC-20230316NUNE\Administrator
2024-02-02 15:38:13 +08:00
parent 877dca3b43
commit 00f56e11c7
228 changed files with 36944 additions and 20084 deletions

View File

@@ -118,7 +118,7 @@ namespace Pathfinding.Legacy {
// gets confused because the first point in the path is far away
// from the current position (possibly behind it which could cause
// the agent to turn around, and that looks pretty bad).
Vector3 p1 = Time.time - lastFoundWaypointTime < 0.3f ? lastFoundWaypointPosition : p.originalStartPoint;
Vector3 p1 = GetSync().Time.time - lastFoundWaypointTime < 0.3f ? lastFoundWaypointPosition : p.originalStartPoint;
Vector3 p2 = GetFeetPosition();
Vector3 dir = p2-p1;
float magn = dir.magnitude;
@@ -154,7 +154,7 @@ namespace Pathfinding.Legacy {
} else if (rigid != null) {
rigid.AddForce(dir);
} else {
tr.Translate(dir*Time.deltaTime, Space.World);
tr.Translate(dir*GetSync().Time.deltaTime, Space.World);
}
}
@@ -204,7 +204,7 @@ namespace Pathfinding.Legacy {
//Mathfx.DistancePointSegmentStrict (vPath[currentWaypointIndex+1],vPath[currentWaypointIndex+2],currentPosition);
if (dist < pickNextWaypointDist*pickNextWaypointDist) {
lastFoundWaypointPosition = currentPosition;
lastFoundWaypointTime = Time.time;
lastFoundWaypointTime = GetSync().Time.time;
currentWaypointIndex++;
} else {
break;
@@ -245,8 +245,8 @@ namespace Pathfinding.Legacy {
Debug.DrawRay(GetFeetPosition(), forward*sp, Color.cyan);
#endif
if (Time.deltaTime > 0) {
sp = Mathf.Clamp(sp, 0, targetDist/(Time.deltaTime*2));
if (GetSync().Time.deltaTime > 0) {
sp = Mathf.Clamp(sp, 0, targetDist/(GetSync().Time.deltaTime*2));
}
return forward*sp;
@@ -263,7 +263,7 @@ namespace Pathfinding.Legacy {
Quaternion rot = tr.rotation;
Quaternion toTarget = Quaternion.LookRotation(dir);
rot = Quaternion.Slerp(rot, toTarget, turningSpeed*Time.deltaTime);
rot = Quaternion.Slerp(rot, toTarget, turningSpeed*GetSync().Time.deltaTime);
Vector3 euler = rot.eulerAngles;
euler.z = 0;
euler.x = 0;

View File

@@ -34,12 +34,14 @@ namespace Pathfinding.Legacy {
public new bool enableRotation = true;
public new float rotationSpeed = 30;
public void Update () {
public override void OnSyncUpdate(int dt, JNFrameInfo frame, Object input)
{
base.OnSyncUpdate(dt, frame, input);
if (rvoAgent == null) return;
RaycastHit hit;
Vector3 pos = tr.position + CalculateMovementDelta(Time.deltaTime);
Vector3 pos = tr.position + CalculateMovementDelta(GetSync().Time.deltaTime);
if (mask != 0 && Physics.Raycast(pos + Vector3.up*height*0.5f, Vector3.down, out hit, float.PositiveInfinity, mask)) {
pos.y = hit.point.y;
@@ -49,7 +51,9 @@ namespace Pathfinding.Legacy {
tr.position = pos + Vector3.up*(height*0.5f - center);
if (enableRotation && velocity != Vector3.zero) transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(velocity), Time.deltaTime * rotationSpeed * Mathf.Min(velocity.magnitude, 0.2f));
if (enableRotation && velocity != Vector3.zero) transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(velocity), GetSync().Time.deltaTime * rotationSpeed * Mathf.Min(velocity.magnitude, 0.2f));
}
}
}

View File

@@ -47,7 +47,7 @@ namespace Pathfinding.Legacy {
public override void OnSyncUpdate(int dt, JNFrameInfo frame, Object input)
{
base.OnSyncUpdate(dt, frame, input);
deltaTime = Mathf.Min(Time.smoothDeltaTime*2, Time.deltaTime);
deltaTime = Mathf.Min(GetSync().Time.smoothDeltaTime*2, GetSync().Time.deltaTime);
if (richPath != null) {
//System.Diagnostics.Stopwatch w = new System.Diagnostics.Stopwatch();
@@ -61,7 +61,7 @@ namespace Pathfinding.Legacy {
//tr.position = ps;
//Only get walls every 5th frame to save on performance
if (Time.frameCount % 5 == 0 && wallForce > 0 && wallDist > 0) {
if (GetSync().Time.frameCount % 5 == 0 && wallForce > 0 && wallDist > 0) {
wallBuffer.Clear();
fn.FindWalls(wallBuffer, wallDist);
}
@@ -255,7 +255,7 @@ namespace Pathfinding.Legacy {
}
UpdateVelocity();
lastDeltaTime = Time.deltaTime;
lastDeltaTime = GetSync().Time.deltaTime;
}
/// <summary>Update is called once per frame</summary>