This document is about: QUANTUM 3
SWITCH TO

Getting Started

Creating character with KCC prefab variant

The easiest way to create custom character is to create a prefab variant from default KCC prefab:

  1. Right click on KCC prefab (in Assets/Photon/QuantumAddons/KCC/AssetDB/Entities).
  2. Select Create > Prefab Variant.
Create prefab variant
Create KCC prefab variant
  1. Add your own visual, add custom components.
  2. The character is ready for use. Continue with Moving the character

Creating character from scratch

  1. Create a new player prefab.
Create player prefab
Create player prefab
  1. Add Quantum Entity View and Q Prototype KCC components to the root game object. Optionally add Capsule Collider.
Add components
Add components to player prefab
  1. Configure the game object
  • Set game object layer (optional).
  • On Quantum Entity View set Bind Behaviour to Verified.
  • On Quantum Entity Prototype set Transform to 3D.
  • Enable PhysicsCollider3D and link previously created Capsule Collider to SourceCollider (optional).
  • On Q Prototype KCC set reference to a KCC Settings asset.
  1. The character is ready for use. Continue with Moving the character

Configuring KCC behavior

The KCC addon contains some pre-configured assets.

  1. Select Assets/Photon/QuantumAddons/KCC/AssetDB/KCCSettings.asset to configure defaults (radius, height, collision layer mask). These should match values in capsule collider created above.
Configure KCC settings
Configure KCC settings
  1. Link KCC processors if you are creating new KCC Settings asset. These are responsible for actual movement logic, more info can be found in Processors section. Default processors are located in Assets/Photon/QuantumAddons/KCC/AssetDB/Processors.

Moving the character

The movement is processed in KCC component update. This is managed by KCC System, therefore it must be added to your Systems Config.

Add KCC System
Add KCC System

Following code example sets character look rotation and input direction for KCC which is later processed by EnvironmentProcessor (or your own processor).

C#

public unsafe class PlayerSystem : SystemMainThreadFilter<PlayerSystem.Filter>
{
    public struct Filter
    {
        public EntityRef Entity;
        public Player*   Player;
        public KCC*      KCC;
    }

    public override void Update(Frame frame, ref Filter filter)
    {
        Player* player = filter.Player;
        if (player->PlayerRef.IsValid == false)
            return;

        KCC*   kcc   = filter.KCC;
        Input* input = frame.GetPlayerInput(player->PlayerRef);

        kcc->AddLookRotation(input->LookRotationDelta.X, input->LookRotationDelta.Y);
        kcc->SetInputDirection(kcc->Data.TransformRotation * input->MoveDirection.XOY);

        if (input->Jump.WasPressed == true && kcc->IsGrounded == true)
        {
            kcc->Jump(FPVector3.Up * player->JumpForce);
        }
    }
}

It is also possible to skip processors functionality completely and simply set the velocity using kcc->SetKinematicVelocity();.

More movement code examples can be found in Sample Project.

Back to top