# 2. Physics

## Physics

This scene will show you how to use **coherence** to sync GameObject transforms and Physics objects across the network.

In this example, each client will have its own player character to move. Left-clicking on the map will make the entity move to that location. Right-clicking will spawn local physics based objects that all player characters can interact with. Each client will only have control over its local entity.

![](https://3580906557-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUrQ8GJkdHxImzMEWuxaz%2Fuploads%2Fgit-blob-dc24cd2dc24e19c434ceccc88180020eea77b3c6%2Fezgif.com-gif-maker%20\(15\).gif?alt=media)

### General Set Up

In the *Hierarchy* of the Scene you can see three core Prefabs:

`Core Scene Setup` and `Coherence Setup` are present in all scenes and described in detail on [Start Tutorial](https://docs.coherence.io/0.8/tutorial-project/network-playground) page.

`Coherence Entity` is the prefab that will change per Scene with different functionality. It has a standard `CharacterController`and `Rigidbody` as well as an `Agent` script which will handle movement functionality through the `Input Manager` in the `Core Scene Setup` prefab.

`Coherence Connection Events` handles overall Scene connectivity. Additionally, it removes all Entities with `coherenceSync` from the Scene to demo disconnection/reconnection via the Interface without refreshing the Scene.

### In This Scene...

`Coherence Entity Character` (always change the prefab, not the instance) is located in the *Resources* folder. The `UnityEngine.Transform` and `position` are ticked to sync. All other settings (persistence and authority) use the default settings. This entity will be session based, no authority handover and no adoption will take place, when a client leaves.

The `On Network Instantiation` event is used to change the colour of the mesh.

The `Physics Entity Spawner` is a simple script to instantiate a `Coherence Entity Physics` Prefab with a coherenceSync component that replicates the transform and position. The component also changes the material based on if it is locally simulated or synced over the network.

![](https://3580906557-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUrQ8GJkdHxImzMEWuxaz%2Fuploads%2Fgit-blob-9baf3a61106bde827e3cf540b9a5fae431c09514%2FPlayground_Scene2%20\(1\).png?alt=media)

### Build and Try

You can build this Scene via the Build Settings. Run the local Replication Server through the *Window -> Coherence -> Settings* window and see how it works. You can try running multiple clients rather than just two and see replicating for each.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coherence.io/0.8/tutorial-project/network-playground/physics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
