This document is about: FUSION 2
SWITCH TO

このページは編集中です。更新が保留になっている可能性があります。

Debugging and Testing

Build and Run

The simplest way to test the sample in multiplayer is to use Unity's "Build And Run" feature (File > Build And Run). This will create a build of the game and immediately launch it alongside your editor instance. While the first build may take several minutes, subsequent builds are much faster since Unity only needs to rebuild what has changed.

Multiplayer Play Mode

Unity 6 introduces a handy new feature called Multiplayer Play Mode that makes testing multiplayer games faster. This feature allows you to launch multiple game instances directly from the Unity Editor without having to build the game. The sample project is already configured to work with Multiplayer Play Mode out of the box.

To use Multiplayer Play Mode in the sample:

  1. Open the Multiplayer Play Mode window (Window > Multiplayer > Multiplayer Play Mode)
  2. Activate one or more Virtual Players
  3. Start the game in Unity Editor as usual by clicking on the Play button
  4. Each instance will run in its own window, allowing you to test multiplayer functionality

State Machine Debugging

The sample project makes extensive use of the Finite State Machine (FSM) addon to control both player and enemy behavior. For help debugging these state machines, please refer to the FSM addon documentation page.

Enemy AI Debugging

The sample includes a custom Enemy Inspector tool to help debug enemy behavior and enemy spawners during runtime. To use it:

  1. Open the Enemy Inspector window by selecting Tools > Fusion MMO > Enemy Inspector
  2. Enter Play Mode in the Unity Editor
  3. Select an Enemy or EnemySpawner GameObject in the Scene view

For enemies, the inspector shows:

  • Basic information like state authority, spawner ID and area ID
  • Debug logging/drawing controls
  • Stats including level, health and position
  • Current and previous AI state
  • Blackboard variables used by the AI (spawn position, target, line of sight etc.)
  • NavMesh agent details like speed, path status and destination

For enemy spawners, the inspector displays:

  • Basic spawner information
  • Current enemy count
  • List of all spawned enemies with their network IDs and state authorities

The inspector window updates in real-time as you play test the game, making it easier to track and debug enemy behavior.

Player AI

The sample includes a basic AI system for controlling player characters, which is useful for testing gameplay mechanics and large-scale scenarios. The AI is implemented in the PlayerAI component and handles navigation, combat, and area exploration using NavMesh for pathfinding.

During gameplay in the Unity Editor, you can toggle AI control for any player character by pressing the 'I' key. When enabled, the AI will:

  • Navigate between different game areas
  • Search for and engage enemies in combat
  • Attack enemy targets
  • Explore the current area when no enemies are detected

This AI system serves as the foundation for automated bot testing, where large numbers of AI-controlled players can joint the game to stress test the game systems and networking (see Large Scale Testing).

You can customize the AI behavior through the Inspector by modifying parameters such as wander areas, debug logging, and other settings on the PlayerAI component located on the Player prefab.

Large Scale Testing

The sample includes support for large-scale testing with multiple connected clients using batch mode and multi-peer functionality.

[YOUTUBE: Batch testing video]

There are two ways to perform large-scale testing:

Using Batch Files

  1. Build the game in Unity
  2. Copy the batch files from the Batch Testing folder to your build location (next to FusionMMO.exe)
  3. Run BatchStart-10Clients.bat to start 10 client instances that will automatically connect to a session named "BatchTest"
  4. You can run the batch file multiple times to add more clients (limited by your PC resources)
  5. To stop testing, run BatchKillAll-FusionMMO.bat to terminate all FusionMMO processes

To monitor the behavior of all connected clients, you can join the game either through the Unity Editor or by launching a separate instance of the FusionMMO game. Enter "BatchTest" as the room name to ensure you join the same session as the bots.

Using Unity Editor

You can also run batch mode simulation directly from the Unity Editor:

  1. Locate the BatchModeManager object in the Game scene
  2. Enable "Simulate Batch Mode" in the Inspector
  3. Configure the number of clients and other settings as needed
  4. Start the game in Play Mode

The BatchModeManager will spawn the specified number of client instances, each running with its own NetworkRunner and connecting to the same session. This allows you to test networking behavior, game performance, and gameplay mechanics at scale.

Back to top