mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交
This commit is contained in:
@@ -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;
|
||||
|
@@ -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));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user