# InvalidOperationException：NetworkTransform：NetworkId 为 42 的对象已有所有者。无法分配新所有者。

- **ID:** `unity/network-transform-ownership-conflict`
- **领域:** unity
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

尝试分配已由其他客户端拥有或未正确释放的网络化对象的所有权。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Netcode for GameObjects 1.6.0 | active | — | — |
| 1.7.0-pre.1 | active | — | — |

## 解决方案

1. ```
   Use `if (networkObject.IsOwner) networkObject.RemoveOwnership();` then wait one frame before assigning new owner using a coroutine.
   ```
2. ```
   Before assigning, check `networkObject.NetworkManager.IsServer` and only allow server to change ownership via `networkObject.ChangeOwnership(clientId)`.
   ```
3. ```
   Implement a custom ownership queue on the server: when a client requests ownership, the server releases the current owner first, then assigns.
   ```

## 无效尝试

- **** — RemoveOwnership() is asynchronous; ownership may not be released by the time the new assignment is attempted. (60% 失败率)
- **** — Spawning a new object avoids the conflict but causes resource bloat and breaks game logic expecting a single instance. (25% 失败率)
- **** — This hides the object from all clients, which may prevent the ownership error but breaks visibility requirements. (70% 失败率)
