Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions com.unity.netcode.gameobjects/Documentation~/samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ Use the samples in this section to learn how to use Netcode for GameObjects in y

| **Topic** | **Description** |
| :------------------------------ | :------------------------------- |
| **[NetworkBehaviour](components/core/networkbehaviour.md)** | [NetworkBehaviour](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.NetworkBehaviour.html) is an abstract class that derives from [MonoBehaviour](https://docs.unity3d.com/ScriptReference/MonoBehaviour.html) and is primarily used to create unique netcode or game logic. To replicate any netcode-aware properties or send and receive RPCs, a [GameObject](https://docs.unity3d.com/Manual/GameObjects.html) must have a [NetworkObject](components/core/networkobject.md) component and at least one NetworkBehaviour component. |
| **[Synchronize](components/core/networkbehaviour-synchronize.md)** | You can use NetworkBehaviours to synchronize settings before, during, and after spawning NetworkObjects. |
| **[Bossroom](samples/bossroom/bossroom-landing.md)** | The Boss Room sample is a multiplayer game that demonstrates how to use Netcode for GameObjects to create a networked game. It provides a complete example of how to implement various features such as player movement, combat, and game state management in a multiplayer environment. |
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ The [2D Space Shooter Project](https://github.com/Unity-Technologies/com.unity.m

## Server Authoritative Physics Movement

The movement in 2DSpaceShooter is physics based. The player object is a dynamic rigidbody and can collide with other players or asteroids. Physics in multiplayer games can be hard to get right. For simplicity, 2DSpaceShooter runs all movement and physics just on the server-side.
The movement in 2DSpaceShooter is physics based. The player object is a [dynamic Rigidbody](https://docs.unity3d.com/Documentation/Manual/2d-physics/rigidbody/body-types/dynamic/dynamic-body-type-reference.html) and can collide with other players or asteroids. Physics in multiplayer games can be hard to get right. For simplicity, 2DSpaceShooter runs all movement and physics just on the server-side.

The client sends inputs in the form of RPCs to the server. The server then uses those inputs to adjust the throttle and turn values of the player.

This method of running physics makes sure that there are no desyncs or other physics issues between the client and server, but it introduces more latency.

## Player Health

2DSpaceShooter uses `NetworkVariable`s to track the players health and energy. Both variables are server authoritative, only the host or server can make changes to them. The client draws the player's health bar simply by accessing the value of the `NetworkVariable`.
2DSpaceShooter uses [NetworkVariables](../../basics/networkvariable.md) to track the players health and energy. Both variables are server authoritative, only the host or server can make changes to them. The client draws the player's health bar simply by accessing the value of the `NetworkVariable`.

For example:

Expand All @@ -34,9 +34,9 @@ https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blo

## NetworkObject Pooling

The `2DSpaceShooter` object creates many objects dynamically at runtime including bullets, asteroids, and pickups. 2DSpaceShooter uses object pooling to avoid performance issues of instantiating and destroying Unity Objects all the time and creating allocations in the process.
The `2DSpaceShooter` object creates many objects dynamically at runtime including bullets, asteroids, and pickups. 2DSpaceShooter uses [object pooling](../../advanced-topics/object-pooling.md) to avoid performance issues of instantiating and destroying Unity Objects all the time and creating allocations in the process.

2DSpaceShooter uses the NetworkObjectPool script, which can be found in the Community Contributions Repository.
2DSpaceShooter uses the NetworkObjectPool script, which can be found in the [Community Contributions Repository](https://github.com/Unity-Technologies/multiplayer-community-contributions).

![pool img](../../images/bitesize/invader-networkobjectpool.png)

Expand Down