Application of Large Language Model in Connecting Non-Player
Characters Intelligent Conversations
Peiyuncheng Ding
a
Shen Fu Yucai Experimental School International High School, Liao Ning, Shen Yang 110000 China
Keywords: Unit, Non-Player Character, Large Language Model, Intelligent Dialogue.
Abstract: The large language model is a kind of Advanced natural language processing model. By inserting the large
language model, non-player characters can understand the question and flow the personal character of non-
player characters from players. This kind of intelligent dialogue not only can improve the game experience
of players but also can improve the interaction and fun of the games. This paper will link the large language
model to the non-player characters to communicate with non-player characters. By using Unity, Ollama and
ChatGPT3.5 and build API communication interface and some optimization. This paper has solved some
problems of Performance optimization of large language models and let the reply be closer to the character's
personality and also improve the interactivity and the experience of players. Finally, this paper has linked the
large language model with non-player characters in the game successfully and chats with it fluently and
continually. In the future, there must be a more efficient and perfect solution to link the large language model
to the non-player characters of games to provide a better experience for players.
1 INTRODUCTION
Video games have evolved significantly at the global
level, offering players different experiences that are
each more immersive and staffing that are very
similar to a real scenario. (Aguas, Toasa, Urdaneta, et
al, 2024) And in the current field of game
development, Players have increasing expectations
for non-player characters in games, especially in
aspect of interactivity. Although, traditional dialogue
system can achieve basic interaction, it is too boring
for players. Whether a game can be loved by players
and maintain long-term interest in the game depends
on whether the behaviour of non-real players in the
game is similar to that of real players, in other words,
whether it can be truly anthropomorphic. (Meng,
2015) With the technology development especially
large language model, like ChatGPT. However, to
develop a stealth game non-player characters AI
system is difficult. (Lin, Zhang, Sun, et al, 2024)
From the current development status of computer
online games, there are many different algorithms
that can achieve artificial intelligence behavior. In
practical production, each algorithm has its own
advantages and specialties, such as the commonly
a
https://orcid.org/0009-0004-4189-2612
used finite state machines and behavior trees. (MAO,
2016)
This paper will using Application
Programming Interface (API) to conect Ollama
modle with the non-player characters in games. The
final target is players can chat with the non-player
characters fluently and non-player characters can
follow the order to give precise answers is also very
important. It is very difficult for this task. First,
because Ollama modle Need to rely on CPU, GPU
and RAM to operation, so, the response from large
language model of computers with low configuration
will be very slow and even have errors. So change a
large language model to make sure the fluency of
games is important. In the end this essey down the
target successfully.
In 2024 Chen qijie had offer an essay it name is
AI reinventing games and it had discribe in the AI is
transforming the gaming industry had passthe
specific cases and analysis the industry, to show the
application, advantages and challenges of AI in game
development also had discribe thefuture development
trend is predicted. (Chen, 2024) And in the same year
Degen, C. had public the essay about Managers
racing to keep ahead of growing threats: AI making
Ding, P.
Application of Large Language Model in Connecting Non-Player Characters Intelligent Conversations.
DOI: 10.5220/0013235000004558
In Proceedings of the 1st International Conference on Modern Logistics and Supply Chain Management (MLSCM 2024), pages 135-138
ISBN: 978-989-758-738-2
Copyright © 2025 by Paper published under CC license (CC BY-NC-ND 4.0)
135
detection more difficult, making it a 'cat and mouse
game' (Degen, 2024) And in 2023 Wang Ming had
conducts research on the problem of game AI
pathfinding based on reinforcement learning. (Wang,
2023)
And in 2020 Min Guohao had public the essay
about Design and implementation of card game AI
system based on supervised learning. (Min, 2020)
This paper will basic on these essay to explore how to
conect the AI into games.
Nowadays, ChatGPT bring the application of
generative artificial intelligence in various of fields
such as journalism, design industry and game
industry, which has changed the human and the way
of communication. (Zhou, Zhang, 2023) This paper
will use Unity to link the Ollama with non-player
characters in games. Let non-player characters have
an intelligent dialogue with players. To improve the
immersion and interactivity of the game and improve
the gaming experience for the player by intelligent
dialogue.
Exploring new areas is definitely exciting, and
video games are a new thing that combines many
fields, including animation, character design, level
design, music, visual art.(Liu, 2023) In the future,
engineers can let non-player characters "come alive"
to bring some richer, more fun gaming experience. It
not only an important breakthrough on game
development, but also provides some solutions for
future game development and innovation.
2 RESEARCH METHOD
2.1 Programming Environment
Preparation
In this part three things are needed: 1. Unity app to
crate the scene and the character 2. large language
model Ollama local language model and ChatGPT3.5
3. Vision Studio to programming the C sharp
programming language.
2.2 Model Deployment
2.2.1 Deploy of Large Language Model
This paper had prepared two types of large language
model Ollama local large model and ChatGPT3.5
network large model. Ollama need to download and
install, and this requires at least 4G of memory and at
least 16G of RAM. However, ChatGPT3.5 need login
an ID of OpenAI.
2.2.2 The Construction of the Game Scene
This requires the deployment of character models
*1
as
well as scenes and dialog systems. Also, here need
adds some actions for model. The built game scene is
shown in the picture below as shown in Figure 1:
Scene construction this paper had put the model in the
mid and there is a background behind it and a dialog
box.
Figure 1: Scene construction (Photo/Picture credit:
Original).
*1 The character model and background used in this paper
are from the Genshin Impact produced by MiHoYo Co., Ltd.
2.3
Communication Between Unity and
Ollama Large Model
Here this paper using C# programming language to
programme the API include sand the request from
players to large language model and give back the
answers to players by large language model. Then
attach the code to the character model and dialog
system.
2.3.1 Design the API for Ollama
Because of the official website of Ollama has already
show the code of API, so this paper can use it directly.
But to make sure it will work correctly in the local
environment, so debug the API code is also needed
and configure the port number of API, it always be
the installation address of Ollama.
MLSCM 2024 - International Conference on Modern Logistics and Supply Chain Management
136
Figure 2: The Response processing of Ollama (Photo/
Picture credit: Original).
As the figure 2 show, firstly, start the Ollama and
make sure it can receive and dispose the data. Then
using the dialog system in Unity to send messages to
Ollama by API. Normally, it uses the HTTP and
POST to send the texts from players to the API
endpoint. When the request comes to the servers, it
will be parsed and pre-processed including cleaning
the text, removing invalid characters. Then send it to
large language model to generate response. And it
will send bake to the Unity. Finally, Attach the code
file to the character model.
3 TEST AND OPTIMIZATION
3.1 Test Results
After the programming code, testing the code is
needed. Typing some simple questions in the dialog
system for example: Hello, who are you? The model
responded successfully and complied with the
personality of character.
Figure 3: Test results (Photo/Picture credit: Original).
The result is showing as Figure 3: Test results.
The large language model had given the response and
is showed on the screen the responds was: Hutu gives
a sly grin, eyes twinkling with mischief* Ah, you
wanna know who I am, huh? Well, let me tell you, I'm
Hutu, the one and only, I'm a bit of a troublemaker,
always looking for ways to get into scrapes and stir
up some, drama. But hey, that's just part of being a
Liyue Qixing, right? *winks* Because the Ollama
depends on the CPU, GPU and RAM to calculate, so
it's going to be very slow, it had use for 50 seconds.
3.2 Optimize
Follow the test results some problem need to be
solved. Because of the Ollama Rely on the CPU, GPU
and RAM, but ChatGPT3.5 rely on the internight, so
it is a better choice for the problem. So, design a good
API is needed.
3.2.1 Design the API for ChatGPT3.5
As shown in figure 4, when the player enters a
question in the dialog system. These requests are
usually sent to API endpoints by using HTTP JOSN.
To ensure that only paying users can use API of
ChatGPT, API authentication is required. API of
OpenAI usually using API Key to authentication. API
Key is sent in the request to verify the identity of users.
When the request reaches the API server, the server
parses the content and preprocesses then it will send
to the large language model. Next GPT3.5 will give
the reply and turn back to the Unity to show for users.
Figure 4: The Response processing of ChatGPT 3.5 (Photo/
Picture credit: Original).
3.2.2 Optimize Test Results
When the code is modified the second experiment
began. Taping the same question as first time: Holle,
who are you. ChatGPT3.5 was also successfully
given the answer by using shorter times.
The optimized program takes only 10 seconds,
which is 40 seconds faster than Ollama. The second
test result is showing as Figure 5: Second test result.
Application of Large Language Model in Connecting Non-Player Characters Intelligent Conversations
137
Figure 5: Second test result (Photo/Picture credit: Original).
The ChatGPT3.5 had given the answer
successfully and faster than Ollama the. Response
was looks at you with a hint of mischief in her eyes*
Oh, I'm the one and only Hououin Kyoukai, but my
friends call me Diao Mu. *smirks*You can just call
me Houhou for short, though. What's your story?
This not only solves the problem of the large language
model depending on CPU, GPU and RAM, but also
reduces the internal storage of the program and
provide a better experience for the players.
4 CONCLUSIONS
This paper linking the large language model into the
non-player characters in games to achieve having
Intelligent dialogue with non-player characters and it
can also improve the Interactivity and player
experience of games. This paper successfully
completed the model deployment of the game, API
programming, programming in Unity, text display
and interaction design and optimization. During the
working process of this paper which had face a lot of
challenges including chose better large language
model, improved the efficiency of the model,
improved the efficiency of the model, and make sure
that naturalness and coherence of dialogue. This
paper not only solved all the problems by effective
solutions and optimization measures, but also ensures
the smooth experience for players when they are
talking to the non-player characters.
This paper not only had improved the immersion
and interactivity of the game successfully, but also
allows players to have an intelligent dialog with the
non-player characters. Therefore, during the working
process this paper had have accumulated many
valuable experience and technology and provided
some new ideas and methods for the development of
games in the future.
In the future, this system can be optimized and
expanded to achieve more application scenarios and
functions in the future. Overall, this paper has not
only achieved the technical goals and functions, but
also provides a successful mothed for the intelligent
dialogue system in games. This paper hopes to
provide some references and research direction for
the research in this field in the future.
REFERENCES
Aguas, L., Toasa, R., Urdaneta, M., Martinez, D., & Suárez,
L., 2024. Desarrollo de "machay": Un videojuego de
misiones espaciales en unity con metodología árcade.
[Development of'Machay': A Space Mission Video
Game in Unity with Arcade Methodology] Revista
Ibérica De Sistemas e Tecnologias De Informação,
564-577.
Meng, S. Q., 2015. Research on Intelligent behavior of
Non-Real Player (non-player characters) based on
Unity3D. Beijing Forestry University.1-66
Lin, Z., Zhang, Z., Sun, X., Zheng, H. T., 2024. Make non-
player characters More Realistic: Design and Practice
of a Hybrid Stealth Game non-player characters AI
Framework Based on OODA Theory. In: Stephanidis,
C., Antona, M., Ntoa, S., Salvendy, G. (eds) HCI
International 2024 Posters. HCII 2024. Commu-
nications in Computer and Information Science, vol
2117. Springer, Cham.
Mao, X. Y., 2016. Intelligent behaviour analysis of non-real
players (non-player characters) based on Unity3D.
Digital Technology and Application, (11):115
Chen, Q. j., 2024. AI transforming Game Industry.
Economic Observer, 19.
Degen, C., 2024. Managers racing to keep ahead of growing
threats: AI making detection more difficult, making it a
'cat and mouse game'. Pensions & Investments, 52(8), 13.
Wang, M., 2023. Based on the reinforcement learning
problem of game AI pathfinding research. Xi An
university of electronic science and technology, 1-79.
Min, G. H., 2020. Design and Implementation of AI system
for card games based on Supervised Learning.
Huazhong university of science and technology, 1-58.
Zhou, H. Y., Zhang, Y. C., 2023. On the New Form of
Posthuman Communication Opened by Soft Artificial
Life: An Analysis of the Media Relationship of non-
player characters in Intelligent Games in the Context of
ChatGPT. Media Criticism, 170-188.
Liu, R. Y., 2023. Case design and practice of casual game
based on Unity3D. Tomorrow’s fashion, 90-92.
MLSCM 2024 - International Conference on Modern Logistics and Supply Chain Management
138