Setting up the Semantic Godot Project
Creating a New Godot Project
Launch Godot
Click
+ New Projectin 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.
- 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
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
Create ArguingTrolls.cs:
using Godot; using Microsoft.SemanticKernel; public partial class ArguingTrolls : Node2D { public override void _Ready() { GD.Print("Semantic Kernel is ready!"); } }
Run the Scene: Press
F6or click theRun Current Scenebutton.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.
- 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.
Configure API Key in .NET:
dotnet user-secrets init dotnet user-secrets set "OPENAI_API_KEY" "YOUR_API_KEY"
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 = ...