This commit is contained in:
2026-07-11 17:07:32 +08:00
parent 9e0d1f04ba
commit d2c8d91748
9 changed files with 733 additions and 71 deletions
@@ -62,13 +62,30 @@ public class BullitMove : MonoBehaviour
transform.position = vector3_startPosition;
}
/// <summary>对象池回收前调用:重置所有运行时状态,避免复用时残留旧数据</summary>
public void ResetState()
{
userid = null;
playerID = null;
bulletID = null;
currShowTime = 0f;
isTriggerFirst = true;
target = null;
targetTra = null;
// 解除锁定 + 恢复碰撞器
NotLock();
// 重置起始位置(z=-400 是原 Awake→Init 的默认值)
vector3_startPosition = transform.position;
vector3_startPosition.z = -400;
}
void Update()
{
// 子弹生命周期:超时自动销毁(默认10秒)
currShowTime += Time.deltaTime;
if (currShowTime >= desTime)
{
Destroy(gameObject);
BulletPool.Instance.Return(gameObject);
return;
}
@@ -136,7 +153,7 @@ public class BullitMove : MonoBehaviour
monster.monsterData.charactersHealth.OnHurt(10, CharacterHurtType.none);
Destroy(monster.gameObject);
}
Destroy(gameObject);
BulletPool.Instance.Return(gameObject);
}
}
}
@@ -228,6 +245,6 @@ public class BullitMove : MonoBehaviour
}
monster.OnHurt();
Destroy(gameObject);
BulletPool.Instance.Return(gameObject);
}
}