Examples
ECM2 encompasses a diverse set of examples designed to assist you in maximizing its potential.
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.
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
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.
This example facilitates easy integration into Unity projects, offering customizable parameters for follow distance, sensitivity, and pitch constraints.
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.
Last updated