Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

Player2 AI NPC for Godot

An asset by ajelefantgg
The page banner background of a mountain and forest
Player2 AI NPC for Godot hero image

Quick Information

0 ratings
Player2 AI NPC for Godot icon image
ajelefantgg
Player2 AI NPC for Godot

The Player2 AI NPC Godot plugin allows developers to easily create AI NPCs in their Godot projects.The plugin uses free AI APIs from the Player2 App at https://player2.game/.Just open Player2, and the plugin connects automatically, so you can dive right into building your world instead of wrestling with keys or settings. When your game is ready, we’ll share it with our community of 40,000+ active players eager for AI-driven adventures: https://player2.game/discordFor usage information, visit the following:https://github.com/elefant-ai/player2-ai-npc-godot/

Supported Engine Version
4.4
Version String
0.25
License Version
GPLv3
Support Level
community
Modified Date
11 days ago
Git URL
Issue URL

Player2 AI NPC Plugin for Godot

The Official Player2 AI NPC Plugin for Godot

The Player2 AI NPC Godot plugin allows developers to easily create AI NPCs in their Godot projects.

The plugin uses free AI APIs from the player2 App

Just open Player2, and the plugin connects automatically, so you can dive right into building your world instead of wrestling with keys or settings. When your game is ready, we’ll share it with our community of 40,000+ active players eager for AI-driven adventures on our discord

Usage Guide

Installing the plugin

Most up to date download is here on github. Feel free to drag and drop only the addons folder into your project.

The plugin is also available in the godot asset library

Creating your Player2 Project and getting the Client ID

Player2 now supports a Web API that requires NO launcher to access, but does require authentication. Thankfully the Godot plugin handles authentication for you, the only thing you need is your client_id.

A backend portal for creating a client_id is present here: https://player2.game/profile/developer

Populate your client_id under Project Settings -> Player2 -> Game Key

Quick start Template

To jump right in with a Chat agent, open templates/chat/chat_template.tscn and get started!

image

Adding the node

To spawn in an AI NPC agent that can talk and perform actions in the world, add a Player2 AI NPC Node:

image

Then, open the node and modify the description of the agent

image

Talking to the Agent

An agent chat example can be found under dev_scenes/simple_chat/simple_chat.tscn

To talk to the agent, call it's chat function. To notify the agent of stimuli from the world, call it's notify function.

For example, we have a simple interface example with a text_sent signal that is fired when the user types in a chat box and presses enter. This can get hooked into the chat function to talk to the agent.

image

Hearing back from the agent can be done with the agent's chat_received signal. Hook this up to a function that can read the agent's reply.

Text To Speech and Player2 Launcher Characters

Access TTS support and the characters from the Player2 launcher using the Character Config

image

You can set the Voice ID to get a custom voice. View all voice IDs here

To have more control over the bot's TTS, you can manually create a Player2TTS node and assign it to the agent. However, a default TTS node is populated automatically at runtime.

Remembering chat history

By default, an agent will remember the previous chat history and greet the player at the start. This can be disabled under the Chat Config:

image

Tool Calling

First, create a script that contains functions that the agent will call.

image

Then, add this script to an empty Node.

Then, drag the new node into the Scan Node for Functions property in the AI NPC node

image

You should now see a list of functions with their descriptions below:

image

Simple chat completion

If you wish to simply run AI/LLM chat completion without history, TTS, or agent replies, use the Player2AIChatCompletion node.

The interface is similar to the Player2AINPC node.

An example can be found under dev_scenes/simple_completion/simple_completion.tscn

Manual TTS (Text To Speech)

Use the Player2TTS node to use Text To Speech manually.

An audio source output will be automatically created for you, but can be manually set in the node.

STT (Speech To Text)

Use the Player2STT node to easily access Speech To Text

However, in order to do this audio must first be enabled in the godot engine.

Enable audio in godot:

Image generation

Use the Player2AIImageGeneration node to generate AI images.

Use the generate_image function and the generation_succeeded signal to receive your generated image. Use cache to avoid hitting the endpoint multiple times for the same image.

An example of generating AI slop can be found under dev_scenes/slop_gen/slop_gen.tscn

Project Settings -> Audio -> Enable Input (turn it on).

Web API Configuration

If you wish to disable the error logging at the top of the screen, customize request timeouts, or customize the authentication UI for the Web API, modify the resource at addons/player2/api_config.tres

image

The Player2 AI NPC Godot plugin allows developers to easily create AI NPCs in their Godot projects.

The plugin uses free AI APIs from the Player2 App at https://player2.game/.

Just open Player2, and the plugin connects automatically, so you can dive right into building your world instead of wrestling with keys or settings. When your game is ready, we’ll share it with our community of 40,000+ active players eager for AI-driven adventures: https://player2.game/discord

For usage information, visit the following:
https://github.com/elefant-ai/player2-ai-npc-godot/

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
Player2 AI NPC for Godot icon image
ajelefantgg
Player2 AI NPC for Godot

The Player2 AI NPC Godot plugin allows developers to easily create AI NPCs in their Godot projects.The plugin uses free AI APIs from the Player2 App at https://player2.game/.Just open Player2, and the plugin connects automatically, so you can dive right into building your world instead of wrestling with keys or settings. When your game is ready, we’ll share it with our community of 40,000+ active players eager for AI-driven adventures: https://player2.game/discordFor usage information, visit the following:https://github.com/elefant-ai/player2-ai-npc-godot/

Supported Engine Version
4.4
Version String
0.25
License Version
GPLv3
Support Level
community
Modified Date
11 days ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers