Setting up the Semantic Godot Project

Creating a New Godot Project

  1. Launch Godot

  2. Click + New Project in the Project Manager and create a new project.

Hello World Script

First, let’s create a simple C# script. Doing so will cause Godot to initialize a dotnet project.

  1. Create a Node and Attach the Script:
    • Create a new 2D scene with a Node2D root.

    • Right click the node and rename it to ArguingTrolls

    • Right click the node and click Attach Script
      • Choose C# as the language

      • This will create ArguingTrolls.cs

    • Save the scene

  2. Open a terminal, navigate to the project directory, and run the following commands to install dependencies:

dotnet add package Microsoft.Extensions.Configuration
dotnet add package Microsoft.Extensions.Configuration.UserSecrets
dotnet add package Microsoft.SemanticKernel --prerelease
  1. Create ArguingTrolls.cs:

    using Godot;
    using Microsoft.SemanticKernel;
    
    public partial class ArguingTrolls : Node2D
    {
        public override void _Ready()
        {
            GD.Print("Semantic Kernel is ready!");
        }
    }
    
  2. Run the Scene: Press F6 or click the Run Current Scene button.

  3. Verify the Output: Look for the message “Semantic Kernel is ready!” in the output console.

For more information on using C# with Godot see https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_basics.html

Configuring the OpenAI API Key

To enable interaction with the OpenAI models through the Semantic Kernel, you need to obtain and configure the OpenAI API key.

  1. Obtain OpenAI API Key:
    • If you don’t already have an OpenAI API key, visit the OpenAI Platform and create an account or sign in.

    • Navigate to the API keys section and generate or copy your API key.

  2. Configure API Key in .NET:

    dotnet user-secrets init
    dotnet user-secrets set "OPENAI_API_KEY" "YOUR_API_KEY"
    
  3. Verify the Secret Configuration: To make sure that the API key is properly stored, run:

    dotnet user-secrets list
    

    You should see the output similar to:

    OPENAI_API_KEY = ...