Skip to content

ChrCtrl AI

Roll4d4 edited this page Feb 24, 2025 · 7 revisions

🕹️ Using KLEP as a Character Controller


🎯 Why Use KLEP for a Character Controller?

Every good AI system starts with a solid foundation. Using KLEP as a character controller allows us to bridge manual input with the same decision-making framework that drives autonomous AI. By acting as the "brain" of the character controller, KLEP demonstrates:

  • Dynamic Reactivity: The system can interpret and respond to input in real-time.
  • Interactivity with KLEP Keys: Inputs are converted to KLEPKeys, showing how user inputs are processed similarly to AI-driven decisions.
  • Process in Action: Even with a limited set of behaviors, KLEP showcases its ability to manage and react to environmental and input-driven changes.

A character controller is an ideal starting point because it offers a controlled, observable environment where human input (keyboard and mouse) is transformed into KLEPKey data and processed by executables.


🧰 What Do You Need for a KLEP Character Controller?

To create a character controller using KLEP, you'll need:

  1. Ground Sensor: Detects when the agent is on the ground.
  2. Input Sensor: Converts mouse and keyboard inputs into KLEPKeys.
  3. Movement Action: Moves the character based on the keys within the KLEP system.
  4. Unity Character Controller: Manages the physical interactions (e.g., gravity, collisions) while KLEP handles the decision-making.
  5. Key Loader: Configures the expected key properties and ensures all behaviors have access to consistent data.

Example Scenario:

When the W key is pressed, the Input Sensor generates a W_Hold KLEPKey.
The Movement Action then interprets this key and instructs the Character Controller to move forward based on the agent's orientation.


🕹️ Character Controller in Action

KLEP Character Controller


🛠️ Step-by-Step Setup Guide


1. Create the Game Object:

  • Create a new GameObject in your Unity scene to act as the root for the KLEP character.

2. Add a Character Controller:

  • Add a Unity Character Controller component to the root object.
    (Note: This handles physics interactions while KLEP handles the decision-making.)

3. Set Up KLEP Structure:

  • Create a child GameObject called KLEP under your root object.
  • Under KLEP, create sub-objects for Sensors, Actions, Routers, and Goals.
    (Keeping components organized will make debugging and expansion easier!)

4. Assign the KLEP Neuron:

  • Attach the KLEPNeuron script to the root object.
  • This transforms the object into a KLEP-enabled agent.

5. Add Sensors:

  • Create child objects under Sensors and add:
    • Ground Sensor: Assign the Key Loader, set the sensor transform to either the sensor object itself or a new child object at the base of the character.
    • Input Sensor: Configure for mouse and keyboard input.

6. Set Up the Movement Action:

  • Add a Movement Action script under the Actions object.
  • Assign the Character Controller (from the root object) to the Movement Action script.

7. Configure the Key Loader:

  • Make sure every script has an assigned Key Loader.
  • Either use the provided Key Loader or create your own (instructions below).
    (🚨 Important: Not assigning a Key Loader may break the system!)

8. Ground Sensor Configuration:

  • Assign the Key Loader.
  • Set the detection radius and ground layer if needed.
  • This sensor should fire every frame, so no locks are needed.

9. Input Sensor Configuration:

  • Assign the Key Loader.
  • Add input events:
    • Click + to add a new event.
    • Select the key from the dropdown (e.g., W, Space).
    • Set the event type (e.g., Continuous, Key Down, Key Up).
    • For a character controller, use Continuous to ensure keys remain active while held.

10. Movement Action Configuration:

  • Assign the Key Loader.
  • Link the Character Controller component to the Movement Action script.

11. Hit Play!

  • Test your setup by pressing Play in the Unity Editor.
  • Your character should now move according to your input, demonstrating the full KLEP process in action.

📽️

GIF: Testing the Character Controller

🔑 Creating a Key Loader

A Key Loader is essential for defining key properties. In this setup, we need it to handle MouseData_KEY properties like MouseScreenPosition and MouseWorldPosition.


🧬 Steps to Create a Key Loader:

  1. Create a Key Loader:
  • Right-click in the Assets window and select KLEP > KeyLoader.

  1. Add Default Properties:
  • Click Add Default Property.

  1. Configure Mouse Properties:
  • In the Custom Property Name field, enter MouseScreenPosition (case-sensitive!).
  • Select Vector3 as the property type.
  • Repeat for MouseWorldPosition.

  1. Done!
  • Your Key Loader is now configured to carry mouse data and ensure all executables receive the expected properties.

📽️

GIF: Creating a Key Loader

🚧 Note:

The Key Loader system is undergoing changes. Future updates may streamline the process and improve system stability. If you encounter issues, double-check that all scripts have valid Key Loaders assigned.


This guide walks you through setting up a KLEP Character Controller, showcasing how manual input can flow through the KLEP system, interact with KLEP Keys, and trigger executables. This is the first step in building a more complex, dynamic AI system where human input can be seamlessly replaced with autonomous decision-making.

KLEP Wiki Navigation

🚀 Getting Started

🧠 Core Concepts

🎮 Examples and Tutorials

🛠️ Scripts and Components

💡 Experimental/Project Projections

🧬 Contributing

Clone this wiki locally