fix:调整联机时最后一波敌人抖动问题
This commit is contained in:
@@ -98,7 +98,6 @@ public class Actions
|
||||
return TaskStatus.Failure;
|
||||
// 计算目标距离
|
||||
float distance = Vector3.Distance(transform.position, target.transform.position);
|
||||
Debug.Log("距离:"+distance);
|
||||
if (distance <= 4f)
|
||||
{
|
||||
playerAi.ai.isStopped = true;
|
||||
@@ -245,7 +244,6 @@ public class Actions
|
||||
if (playerAi == null) return TaskStatus.Failure;
|
||||
if (target.Value != null)
|
||||
targetPos = target.Value.transform.position;
|
||||
transform.LookAt(new Vector3(targetPos.Value.x, transform.position.y, targetPos.Value.z));
|
||||
playerAi.DoAttack(targetPos.Value);
|
||||
return TaskStatus.Running;
|
||||
}
|
||||
|
||||
@@ -237,6 +237,7 @@ public class Enemy : Agent
|
||||
target=(GameObject)behaviorTree.GetVariable("target").GetValue();
|
||||
|
||||
}
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(target.transform.position.ReflectVectorXOZ() - transform.position), Time.deltaTime * 10f);
|
||||
@@ -334,7 +335,7 @@ public class Enemy : Agent
|
||||
}
|
||||
|
||||
// Server 上播放受击(广播给所有客户端)
|
||||
RpcPlayHit(hitPoint);
|
||||
//RpcPlayHit(hitPoint);
|
||||
|
||||
// 伤害计算:默认返回原始值;若你需要韧性(toughness)生效,可在这里调整
|
||||
// 例如:value = Mathf.Max(0f, value - toughness);
|
||||
@@ -507,19 +508,5 @@ public class Enemy : Agent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Debug Gizmos
|
||||
void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawWireSphere(transform.position, 1.5f); // 可替换为攻击范围的字段
|
||||
if (target != null)
|
||||
{
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawLine(transform.position, target.transform.position);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ public class GameManager : NetworkBehaviour
|
||||
// 延迟1s后给所有人发放武器
|
||||
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
||||
{
|
||||
GivePistol();
|
||||
GivePistol(GunType.Pistol);
|
||||
}, 1f);
|
||||
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
||||
{
|
||||
@@ -257,10 +257,10 @@ public class GameManager : NetworkBehaviour
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
public void GivePistol()
|
||||
public void GivePistol(GunType type)
|
||||
{
|
||||
Debug.Log("创建武器中...");
|
||||
GameLocal.Ins.self.PickUpGun(GunType.Pistol, -999);
|
||||
GameLocal.Ins.self.PickUpGun(type, -999);
|
||||
}
|
||||
|
||||
[Server]
|
||||
@@ -288,7 +288,7 @@ public class GameManager : NetworkBehaviour
|
||||
{
|
||||
Debug.LogError("开启End事件");
|
||||
gameState = GameState.EndEvent;
|
||||
GameLocal.Ins.self.PickUpGun(GunType.MeleeWeapon, -999);
|
||||
GivePistol(GunType.MeleeWeapon);
|
||||
foreach (var item in PlayerAiList.Values)
|
||||
{
|
||||
item.EndEvent();
|
||||
|
||||
Reference in New Issue
Block a user