Dev Diaries: Character Customization and Core Gameplay
Welcome back to our Photon Dev Diaries in which we share direct insights of how our partners progress when working on shared projects. In the last part we started giving you an introduction on how Team Nthusia started their Animal Crossing-inspired sample that uses Photon Fusion’s Shared Mode. Now, with the holiday season behind us, giving us all a needed breather, we are back with Part 2 and a closer look at the core mechanics of this sample.
What you can expect in this part of our Dev Diary:
- Core Gameplay Mechanics: Showcasing the interactive actions players can enjoy in a shared social simulation world.
- Fusion Shared Mode: Enabling seamless player collaboration in a client-authoritative network, perfect for casual, community-driven games.
- Shareable Inventory System: Enabling seamless item exchange, persistent ownership, and in-game economy for collaborative gameplay.
- Character Customization: A streamlined system for syncing player appearance efficiently and dynamically in a networked environment.
Putting in Core Gameplay Mechanics
The general idea with this sample is to create a chill social simulation where players join a shared world. Once there, they can explore, interact with the environment, and make changes to the map.
Players have tools like an axe, shovel, net, and watering can, which let them do things like plant and water trees. Over time, the trees grow and produce fruit that can be sold. You can also interact with NPCs to buy and sell items. The gameplay includes activities like chopping trees, digging holes, burying items, and collecting shells. It’s all about relaxing and enjoying a shared, interactive world. The perfect playground for Fusion Shared Mode.
What Is So Special About Fusion Shared Mode?
Fusion supports three network topologies: Server, Host and Shared. Fusion Shared is a 100% client-authoritative mode which means that each of the clients has full authority and instead of depending on a central server or a single host with full authority, all clients run their own game simulations and all update messages are relayed to the other clients via the Photon Cloud. As game clients have full authority over spawning or managing objects, the responsibility for owning and tracking their state is shared across all clients.
Shared Mode is great for more casual games or those with a lot of players, especially when players enter and leave often as this will not disrupt gameplay. It is not only easy to adopt as a developer without deeper knowledge of netcode programming, but also operation costs and complexity is very low.
In fast-paced or competitive games it can get very tricky to keep everything synchronized between players and due to a missing central authority Shared Mode is more vulnerable to cheating. To address cheat-protection, Fusion will also get our proven plugin technology to create and upload custom server code to Enterprise Photon Cloud soon.
The sample that Team Nthusia is working on, which is inspired by Animal Crossing, is perfectly suited for Shared Mode. Players can work together to build and maintain a village – planting trees, trading items, and so on.
The game world grows through everyone’s efforts, with no single player in charge. It’s all about fostering creativity, community, and collaboration.
Using a Shareable Inventory System
The Shareable Inventory System in this sample game has the advantage of easily transferring ownership of dropped items when a player leaves, preventing them from despawning. Players in this sample game will be able to exchange items and money due to the shareable inventory system. The specifics of the money item are still being determined. Players can collect and drop items, including a money item, allowing them to engage in an in-game economy and trade items.
The system ensures that when a player leaves the game, dropped items don’t disappear; instead, their ownership is smoothly transferred to prevent them from despawning. This is made possible by utilizing Fusion Shared, which avoids items being solely tied to a specific client or server. Items within the inventory have specific traits such as “drop,” “plant,” and “bury,” which facilitate their use and sharing among players.
How to Make Your Characters Look Great
Nthusia’s customization system is designed for simplicity and efficiency. Players can customize their characters’ skin, hair, and clothing colors, as well as their hairstyles, hats, and accessories. When the player spawns, these choices are applied to their character and shared with all other players in the game. This system uses the Networked custom INetworkStruct property, which is a way to bundle related data together and make it part of the game’s network simulation. This is more efficient than syncing each piece of data separately.
The customization system prioritizes efficiency in a few ways. First, it uses byte indices to store selections rather than large data values like full RGB color codes. This reduces the amount of data that needs to be sent over the network. Second, all customization data gets wrapped up into a single property, which streamlines the synchronization process.
The INetworkStruct property has an OnChangedRender attribute that automatically updates the visuals whenever the customization data changes. Photon Fusion’s “weaver” handles the sharing of this data, so developers don’t have to worry about it manually.
In this particular sample, the customization data is set up once and then automatically updated using the OnChangedRender callback.
Here is an example:
[Networked(OnChanged = nameof(OnChangedRender))]
public struct CustomizationData : INetworkStruct {
public byte SkinColorIndex;
public byte HairColorIndex;
public byte ClothingColorIndex;
public byte HairstyleIndex;
public byte HatIndex;
public byte AccessoryIndex;
}private void OnChangedRender(Changed<CustomizationData> changed) {
// Apply visual changes here based on updated properties
}
Off to a Good Start
With all these implementations your sample will have a great basis to build on. Like Nthusia, you can use Fusion Shared to create a small world where characters can roam around and players can meet each other. With that we are now ready to set up the final stages of this sample that we will showcase in our next and final part of this Dev Diary, taking a closer look at refining the inventory management, implementing dialogue in a user-friendly way, adding controller support and setting up the sample for release.
Ready to build your own successful multiplayer game? With Fusion and Quantum by Photon, it’s never been easier to integrate cutting-edge multiplayer features into your project. We offer the industry’s most advanced tools, comprehensive support, and everything you need to get started – from downloadable samples to detailed documentation.
Take the first step today – download Fusion or download Quantum and start building. If you’re looking for in-depth assistance, join our Gaming Circle, where you can connect directly with our developers and get expert guidance throughout your journey.
Your multiplayer success story starts here!
Join us on Discord, YouTube, BlueSky , X and LinkedIn – we can’t wait to see what you create!