# Examples

ECM2 encompasses a diverse set of examples designed to assist you in maximizing its potential.

{% hint style="success" %}
For a thorough understanding, it is strongly suggested to read this document alongside the corresponding examples' source code. Each example provides clean, clear, and fully commented source code, offering valuable insights into ECM2 functionality and how to tailor it to your game's requirements.
{% endhint %}

## Demo

This showcases some of the many features that ECM2 offers.

## First Person

This example demonstrates how to extend a `Character` (via inheritance), incorporating support for a standard first-person movement.

## First Person Fly

This example utilizes the first-person character from the previous example and illustrates how to incorporate controls while flying.

## First Person Swim

This example utilizes the first-person character from the previous example and illustrates how to incorporate controls while swimming.

## Glide

This example demonstrates how to implement a **Glide** ability through composition. It utilizes one of the included 'hook' methods to influence the character's behavior without the need to inherit from the `Character` class.

## Jump

This example illustrates how to replace the built-in jump of the `Character`, thereby creating a jump ability. This implementation reproduces the jump behavior from previous versions (before v1.4.0).

## Ladders

This example demonstrates how to implement ladder climbing mechanics by extending a `Character` through composition, introducing a new **Climbing** custom movement mode.

## Networking

{% hint style="info" %}
These examples **illustrate a basic implementation** of ECM2 movement in a networked environment. Please note, they are **not designed to be a complete multiplayer solution** nor do they cover all ECM2 features in networked scenarios. Their primary role is to provide a **foundational starting point** that you can build upon and customize to suit your unique networking framework and project needs.
{% endhint %}

In this section, you will discover examples of major networking libraries, including the latest versions of **Fusion**, **FishNet**, **Mirror**, and **NetCode** for **GameObjects**.

These examples demonstrate the minimal data required to synchronize the `CharacterMovement` component and `Character` class across a network. Among them, the **Fusion** example stands out as the most comprehensive, implementing full client side prediction and reconciliation, and showcasing the implementation of a histogram (circular buffer) to efficiently store local data such as timers, states, and more while preserving full server authority.

The **FishNet** example is limited to synchronizing `CharacterMovement` only.

On the other hand, both the **Mirror** and **NetCode** examples demonstrate how to configure a `Character` to function with client authority. This approach is quite similar to standalone operation, with only minor differences, making it easier to work with and get started.

## Orient To Ground

This example illustrates how to orient a `Character` to follow the contour of a 'terrain'. It samples a predefined area to compute an average normal, which is then used to adjust the character's rotation.

## Planet Walk

This example extends a `Character` through inheritance, modifying its gravity and orientation to mimic a planet's curvature, reminiscent of the gameplay in Mario Galaxy.

## Side-Scrolling

This example demonstrates how to configure and execute typical 2D side-scrolling movement.

## Slide

This example illustrates extending a `Character` through inheritance to implement a slide mechanic. It is realized as a new **Sliding** custom movement mode.

## Slope Speed Modifier

This example demonstrates how to utilize the newly introduced `GetSignedSlopeAngle` function (introduced in v1.4.0) to adjust the characters' movement speed based on the slope angle.

## Teleport

This example shows how to implement a basic teleport system. It enables the teleportation of the `Character` and adjusts its rotation to match the orientation of the teleporter.

## Third-Person Controller

This example serves as a practical demonstration of how to implement a basic third-person character controller.

&#x20;This example facilitates easy integration into Unity projects, offering customizable parameters for follow distance, sensitivity, and pitch constraints.&#x20;

Users can understand and adapt the provided code to establish essential functionalities like character movement, camera rotation, and zoom input.

## Toggle Gravity Direction

This example demonstrates how to extend a `Character` through composition, enabling the modification of its gravity direction with a toggle feature. Additionally, it orients the character along the world-up defined by the gravity direction.

## Twin-Stick Movement

This example illustrates how to extend a `Character` through inheritance, incorporating a custom rotation mode. In this instance, it implements controls typical of a **Mouse** and **Keyboard** twin-stick shooter.


---

# 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://oscar-gracian.gitbook.io/easy-character-movement-2/user-manual/general/examples.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.
