Question Answering
SkillfulAPI.
QuestionAnswering
SkillfulAPI.
QuestionAnswering
Overview
The QuestionAnswering
function is a simple example of how to interact with the SkillfulAI API to get answers based on a given context and question. This functionality can be used to enhance NPC interactions, provide dynamic game feedback, and more.
Function Example
Detailed Explanation
Start Method
Description: Unity's Start method is called once when the script is initialized. This method initiates the question answering process.
Code:
Functionality:
Calls the
Question
method to begin the process.
Question Method
Description: The Question
method handles the question answering logic, using the SkillfulAI API to get a response based on a given context and question.
Code:
Functionality:
Defines a
context
string providing the information needed to answer the question.Defines a
question
string that queries specific information based on the context.Calls
SkillfulAPI.QuestionAnswering
, passing thequestion
,context
, and a callback function to handle the response.The callback logs the API's response to the Unity console.
Usage Example
Add the Script to a GameObject:
Attach the
QuestionAnswering
script to any GameObject in your Unity scene.
Run the Scene:
When you start the scene, the
Start
method is called, which in turn calls theQuestion
method.The
Question
method sends a question and context to the SkillfulAI API and logs the answer to the console.
Conclusion
The QuestionAnswering
function provides a straightforward example of how to leverage the SkillfulAI Gaming SDK to integrate AI-powered question answering into your Unity project. This can be expanded and customized to suit more complex scenarios and interactions in your game.
Last updated