From Idea to Implementation: How Game Developers Can Utilize ChatGPT in Practical Ways
How Game Developers Can Utilize ChatGPT in Practical Ways

Brief overview of ChatGPT and its potential uses in game development

ChatGPT (Generative Pre-trained Transformer) is an artificial intelligence language model that has been pre-trained on a massive amount of text data. It is capable of generating human-like language and can be used for a variety of natural language processing tasks, including text completion, summarization, and translation.

In game development, ChatGPT can be a valuable tool for generating code and providing suggestions or prompts for developers. By inputting a description of a desired game feature or behavior, ChatGPT can generate code that can help developers save time and improve the quality of their work.

For example, ChatGPT could be used to generate code for complex AI behaviors, physics simulations, or other game mechanics. It can also be used to suggest improvements or optimizations to existing code.

While ChatGPT is not a replacement for skilled game developers, it can be a valuable tool to help streamline the development process and allow developers to focus on the creative aspects of game development. As AI and machine learning continue to advance, it’s likely that ChatGPT and other similar tools will become increasingly important in game development and other fields.

Introduction to the specific task of creating floating stones that change speed based on the player’s distance

In an existing game, I was tasked with implementing a group of floating stones that would change behavior as the player moved closer to them. In their idle state, the stones should float smoothly and slowly, but as the player approaches, they should start to jitter more and more.

This required creating a class, implementing dependencies, and other code that couldn’t be achieved through animator controllers or libraries. While this wasn’t a “nightmare” level task, it was still time-consuming. ChatGPT proved to be a useful tool for generating code snippets and saving time in the development process.

Explanation of how ChatGPT can be used to generate code for game development tasks

When working with ChatGPT, it’s important to start with the right context. In my case, I began with a promo message about the technology I planned to use. It’s important to keep in mind that ChatGPT is just a tool and won’t generate ideas or code on its own. You need to provide clear and detailed input for the best results.

That said, ChatGPT can be a real-time-saver. When using the tool, it’s essential to provide a detailed description of what you’re trying to achieve. The more information you provide, the better the output will be. It’s important to note that using ChatGPT should take less time than achieving the same result without it. So, don’t be afraid to put in the effort to provide a detailed description. With ChatGPT, you can streamline your development process and focus on other aspects of your project.

Example prompts and code snippets used to generate the necessary code for this task

Let’s dive into the practical use of ChatGPT. As I mentioned earlier, I started by providing context about my game engine and coding language.

I want to ask you to help us create some code for my game based on Unity SDK, C# code language.

ChatGPT responded kindly, and I moved on to the next step — providing a detailed description of the task and its conditions.

A few words about the context of the task. In the game, players can find floating stones. These stones have random directions of jittering, but this jittering is very smooth. If the player appears within around 10 meters of the stone, the jittering speed becomes faster and the speed depends on the player’s distance to the stone (more if closer).

As a result, ChatGPT provided me with a basic realization of the class I needed to implement. While the code wasn’t perfect, it covered around 80% of what I needed to do.

using UnityEngine;

public class FloatingStone : MonoBehaviour
{
    public float maxSpeed = 1f;
    public float minDistance = 10f;

    private Vector3 initialPosition;
    private float initialSpeed;
    private bool isPlayerNearby;

    private void Start()
    {
        initialPosition = transform.position;
        initialSpeed = Random.Range(0.2f, 0.5f);
    }

    private void Update()
    {
        float speed = isPlayerNearby ? CalculateJitteringSpeed() : initialSpeed;
        transform.position = initialPosition + new Vector3(
            Mathf.PerlinNoise(Time.time * speed, 0) - 0.5f,
            Mathf.PerlinNoise(0, Time.time * speed) - 0.5f,
            Mathf.PerlinNoise(Time.time * speed, Time.time * speed) - 0.5f
        );
    }

    private float CalculateJitteringSpeed()
    {
        float distanceToPlayer = Vector3.Distance(transform.position, 
                                                  PlayerController.instance.transform.position);
        float speed = Mathf.Lerp(initialSpeed, maxSpeed, (minDistance - distanceToPlayer) / minDistance);
        return Mathf.Clamp(speed, initialSpeed, maxSpeed);
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            isPlayerNearby = true;
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            isPlayerNearby = false;
        }
    }
}

Next, I made some corrections — I added context about using Zenject for player injection and refactored the class to align with project conventions. I then asked ChatGPT to use my updated code version and add jittering rotation to the object based on the same conditions.

After this step, I received the final version of the code that I could use in my project. I made some minor changes on my end, and in the last step, I asked ChatGPT to add XML comments to the final class and received the desired result.

The final result of the code


public class FloatingStone : MonoBehaviour
 {
     [SerializeField] private SpeedSettings speedSettings;
     [SerializeField] private float minDistance = 10f;
     [SerializeField] private float amplitude = 0.5f;
     [SerializeField] private float rotationAmplitude = 1f;
     [SerializeField] private new SphereCollider collider;
 
     private Vector3 initialPosition;
     private Quaternion initialRotation;
     private float initialSpeed;
     private bool isPlayerNearby;
     private Transform player;
 
     [Inject]
     private void Constructor(IPlayer player)
     {
         this.player = player.Transform;
     }
 
     private void Awake()
     {
         initialPosition = transform.position;
         initialRotation = transform.rotation;
         initialSpeed = speedSettings.GetRandomSpeed();
         collider.radius = minDistance;
     }
 
     private void Update()
     {
         float speed = isPlayerNearby ? CalculateJitteringSpeed() : initialSpeed;
         Vector3 newPosition = initialPosition + new Vector3(
             Mathf.PerlinNoise(Time.time * speed, 0) - amplitude,
             Mathf.PerlinNoise(0, Time.time * speed) - amplitude,
             Mathf.PerlinNoise(Time.time * speed, Time.time * speed) - amplitude
         );

         Quaternion newRotation = initialRotation * Quaternion.Euler(
             Mathf.PerlinNoise(Time.time * speed, 0) * rotationAmplitude - rotationAmplitude / 2f,
             Mathf.PerlinNoise(0, Time.time * speed) * rotationAmplitude - rotationAmplitude / 2f,
             Mathf.PerlinNoise(Time.time * speed, Time.time * speed) * rotationAmplitude - rotationAmplitude / 2f
         );

         transform.position = Vector3.SmoothDamp(transform.position, newPosition, ref velocity, 0.1f);
         transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, Time.deltaTime * 5f);
     }
 
     private Vector3 velocity = Vector3.zero;
 
     private float CalculateJitteringSpeed()
     {
         float distanceToPlayer = Vector3.Distance(transform.position, player.position);
         distanceToPlayer = Random.Range(distanceToPlayer - 0.1f, distanceToPlayer + 0.1f);
         float speed = Mathf.Lerp(initialSpeed, speedSettings.GetMaxSpeed(), (minDistance - distanceToPlayer) / minDistance);
         return Mathf.Clamp(speed, initialSpeed, speedSettings.GetMaxSpeed());
     }
 
     private void OnTriggerEnter(Collider other)
     {
         if (other.CompareTag("Player"))
         {
             isPlayerNearby = true;
         }
     }
 
     private void OnTriggerExit(Collider other)
     {
         if (other.CompareTag("Player"))
         {
             isPlayerNearby = false;
         }
     }
     
     
     [Serializable]
     private struct SpeedSettings
     {
         [SerializeField] private float max;
         [SerializeField] private float from;
         [SerializeField] private float to;
         
         public float GetRandomSpeed() => Random.Range(from, to);
         public float GetMaxSpeed() => max;
     }
 }

How ChatGPT can save game developers time and improve code quality

ChatGPT is a powerful tool that can help game developers save a significant amount of time and improve the quality of their code. In fact, it can save up to 60–70% of the time needed for task implementation. As a professional developer, I knew how to implement a task from scratch, but still needed to write each line of code, optimize it, and debug it. However, with ChatGPT, I was able to save a lot of time on the first point and focus on the last two points. This is the main idea of my article about using ChatGPT for coding in real life.

In game development, time is a crucial factor. Developers have to work under tight schedules and deadlines. This is where ChatGPT can come in handy. It can help game developers save time by providing them with basic code implementations that they can use as a starting point. With ChatGPT, developers can get a basic realization of the class they need to implement and then modify it according to their needs. Another advantage of using ChatGPT is that it can improve the quality of code. ChatGPT provides developers with different code options that they can use as a reference. This can help developers write cleaner, more efficient code that is easier to maintain and debug.

Related Articles

August 8, 2023
Tactile Training: Revolutionizing Hazardous Industry Preparation with XR and Haptic Technologies

This article was written by our CEO Olga Kryvchenko and originally published on Linkedin. To get more biweekly updates about extended reality, subscribe to Olga’s XR Frontiers LinkedIn newsletter. The power of touch has long been recognized as a potent sensory modality. With the rise of Extended Reality (XR) technologies, touch, or more precisely, haptic feedback, has found its profound significance. Especially in hazardous industries, where direct training poses risks, XR combined with haptic feedback offers a revolutionary approach. Understanding Haptic Feedback At its core, haptic feedback simulates the sense of touch and movement. This tactile feedback, when incorporated in digital interfaces or XR environments, provides users with realistic sensations ranging from a gentle breeze to a jolt from a virtual electric shock. The Evolution of Haptic Devices While the rudimentary concept of haptic technology revolves around vibrations, contemporary haptic devices offer far more intricate feedback. – Glove-based Systems: Pioneering the future of touch in XR, these gloves simulate intricate textures, temperatures, and resistances. Users can virtually touch a hot surface or feel the graininess of sand. – Vest Systems: These aren’t your average vests. They’re equipped to simulate everything from the impact of a bullet to the gentle tap on the shoulder. – Treadmills and Platforms: Beyond letting users walk or run in a virtual space, these devices offer gradients, and resistances, and even simulate different terrains. – Haptic Controllers: These handheld devices can simulate weight, resistance, and more. They’re often used in XR setups where precision is required, like machinery operation or surgical training. Spotlight: Some XR Haptic Innovations 1. Manus Meta Gloves: Advanced haptic gloves that simulate intricate tactile experiences within virtual spaces, ideal for hazardous industry simulations. 2. SenseGlove: Offering unparalleled haptic feedback, this device simulates realistic touch sensations, ensuring authentic training experiences in hazardous industries. 3. Electric Haptic Vest: A revolutionary vest that provides electric haptic feedback, enabling users to feel virtual impacts, touches, and temperature changes, enhancing training realism. These innovations are setting the benchmark for immersive XR training in high-risk sectors, ensuring both safety and efficacy. Incorporating Haptics in XR Training for Dangerous Industries Haptic feedback is not just a fancy addition; it’s a necessity in industries where mistakes can be catastrophic. 1. Realistic Hazard Simulation: XR environments equipped with haptic feedback allow trainees to understand and feel dangerous situations, like the rumble of an impending mine collapse or the heat from an electrical malfunction. 2. Skill Refinement: Fine motor skills can be honed in a virtual space. Imagine a trainee learning to operate a chainsaw; with haptic feedback, they can feel the tug, the resistance, and even the vibration, all without the real danger. 3. Emergency Protocols: Virtual emergencies can prepare employees for real-world crises. These drills aren’t just visual or auditory; haptic feedback ensures they are physically intuitive. Looking Ahead: The Future of Haptic XR Training The fusion of haptic devices and XR promises a future where training for even the most hazardous jobs is thorough, intuitive, and above all, safe. As the fidelity of haptic feedback continues to improve, the line between virtual training and real-world operation will further blur, leading to a workforce that’s adept and prepared for any challenges. In an era dominated by technological advancements, haptic feedback stands out as a game-changer for XR training in dangerous industries. It’s not just about seeing or hearing; it’s about feeling, and that tactile element ensures that trainees are not only knowledgeable but are also instinctively prepared for real-world scenarios. Image: Freepik

July 24, 2023
Virtual Tours of National Parks. Discovering Nature’s Beauty through AR and VR

In this article, we will explore the impact of augmented and virtual reality on national parks, specifically how they are changing our experience of visiting natural landscapes. We focus on free virtual tours that allow us to see the beauty of national parks without leaving home. We will also reveal the main advantages of augmented reality, which enrich the visiting of real parks with the help of digital content with interesting information. In particular, we will share our experience of creating tourist VR excursions using the example of the Carpathian Mountains Virtual Tour and Medieval Fortress Virtual Journey. We will also explore other famous AR/VR use cases, e.g., the State Parks of California, giving us a unique perspective on our national parks’ historical and ecological significance. Discovering Benefits of AR and VR in National Parks Virtual and augmented reality offer such benefits to national parks as Getting informative content on the spot. When visiting parks and other historical places, visitors usually don’t know about this or that type of plant or even in which part of the park they are. With the help of an AR application, a tourist can simply point the screen at a particular plant and get additional information about it. Read also: The Ways AR Redefines Modern Tourism  Speaking about orientation in place, AR navigation will come in handy here, which guides the tourist in the right direction with the help of digital pointers. Read also: From Outdoors to Indoors: AR Navigation as Game-Changer Visiting places that aren’t accessible for you. During the COVID-19 pandemic and home isolation, virtual tours of museums or national parks were one of the popular alternatives to visiting real tourist locations. Even though the pandemic began to gradually fade away, virtual tours continue to be relevant. By visiting free tours on museums or park websites, an Internet user saves money on the ticket, car fuel, and transportation. Especially when a person does not always have an opportunity to get to the place where, perhaps, he would like to go. “The advantage is that you can go somewhere and experience the same feelings without leaving your home. Virtual guides have musical accompaniment, the effect of presence thus allows you to immerse yourself in the environment. This is all about VR. Plus, not all of us can go to Papua New Guinea or somewhere else to look at bamboo, baobabs, etc. Or go on safari. Therefore, these are opportunities to visit somewhere without spending additional funds,” said Oleksandr Ivanov, project manager of Qualium Systems. Drawing attention to ecology, rare plants and animals. As you know, there are more than 35,000 species of endangered plants and animals in the world, 99% of which are endangered due to human activities. With virtual and augmented reality for parks that are the home for these species of animals, it becomes possible to tell about these endangered species to a wider audience. As of July 2023, there are almost 7 billion people in the world who have smartphones, which is more than 86% of the entire population of the planet.  Qualium System’s Virtual Tours of National Parks Qualium Systems has great experience in developing VR excursions. Carpathian Mountains Virtual Tour is an application for Meta Quest, created as part of The World Of Carpathian Rosettes — Activities For Preserving The Cultural Uniqueness Of The Carpathians project by the Euroregion Carpathians — Ukraine association with the financial support of the European Union. The main goal of this program is to preserve the cultural uniqueness of the Ukrainian Carpathians. The main challenge in the development of this virtual tour was to introduce more than 260 photo and video materials into the program while providing the VR headset users with such an experience as if they were visiting a real museum. In this application, a tourist can explore virtual settlements in the Carpathians, both with the effect of presence in these settlements and from a bird’s eye view. There is also the option of a “bicycle trip” available. A tourist can “ride” along the Franko route, which is a path in the forest, famous Ukrainian poet Ivan Franko liked to travel. Also, our developers are working on another virtual tour of the medieval fortress in the Ukrainian town of Tustan. Unlike the previous tour, a VR headset user will not only be able to see the digital environment with exhibits but also interact with them. “With the help of VR, you can not only be there, in that museum, but also take the artifacts, examine, bring them up to your forehead. You could see everything down to every crack,” said Oleksandr Ivanov, project manager of Qualium Systems. Unveiling Diverse Use Cases of AR and VR in National Parks Our company pays attention to virtual tours and giving people the opportunity to see places that are inaccessible to them due to various circumstances. We constantly monitor the latest trends in the modern IT industry, and there are other famous examples that will be mentioned later. Virtual Reality Adventures in California State Parks The California Department of Parks and Recreation has introduced virtual and augmented reality tours for 9 parks located in the state of California. In the Virtual Adventurer mobile app, tourists get a guided tour that tells the story of each of the parks, including Colonel Allensworth State Historic Park, Montana de Oro State Park, Old Town San Diego Historic Park, and others. Moreover, futuristic holograms and 3D reconstructions are also involved. “The app also supports and enhances the department’s Reexamining Our Past Initiative by developing content for parks that tells a more complete, accurate, and inclusive history of people and places,” said California State Parks Director Armando Quintero.  Great Barrier Reef’s Virtual Realms As mentioned above, virtual excursions allow gadget users to get to places they would be unlikely to get to in real life. The same is true for the underwater attractions. Not every tourist wants to spend their time and money not only to reach, for example,…

July 13, 2023
From Novice to Pro: Dive into Best AR/VR Courses for Aspiring XR Developers

In recent years, IT and immersive technologies are one of the most popular fields that people choose for their future careers. According to Statista, as of January 2023, the number of IT workers was 3.1 million, and by 2032 the number of workers will exceed 6 million. Among those starting to work in the field of IT and XR, there are both young professionals and those who have career experience in other fields and want to change their lives. And free online courses, which introduce a beginner to the essence of the matter in an interesting and accessible language, are useful for future developers. In this article, we offer an interesting selection of the best free XR training courses online. Whether you’re looking to develop XR experiences for Unity and Magic Leap 2, shoot a 360o film, or create your own metaverse, our selection of courses will provide you with the necessary skills and knowledge needed for those just starting their XR journey. Create with AR: Face Filters by Unity A training course for those new to AR application development, including creating face filters. This course is designed for those willing not only to learn the basics of programming applications on Unity but also to expand their portfolio with new cases, which will make it much easier to enter the field of XR. The course is divided into three parts: Get Started With AR. The future developer will learn the types of features in augmented reality, such as AR face filters, and AR markers that allow you to place digital content in real space. One will learn how to integrate a finished 3D model design into a game. Create a basic face filter. The main goal of this segment is to create your own customized AR face mask, including creating face trackers and using various textures, 3D models, and other components that can be used for an AR mask; Create an interactive face filter. In the final part of the course, the student has to make their mask interactive. In particular, developers also learn to add a user interface to the created mask and use visual scripts to program functions. A student is able to independently monitor their own progress and mark the completed lessons on the page. The entire course is available here: https://learn.unity.com/course/create-with-ar-face-filters?uv=2021.3  Virtual Reality Development Specialization by the University of London A virtual reality training program by the University of London is designed for beginners and consists of 5 courses. Its total duration is 6 months, 4 hours per week, with a flexible schedule. Each of the 5 training courses contains the following information: Introduction to virtual reality. Students get acquainted with the concept of virtual reality, its history, and basic principles; 3D Models for Virtual Reality. In this course, students will take the first steps in developing 3D models for VR, the basic principles of digital content development, and overlaying models in a digital environment. Students will also learn the basic principles of one of the most common VR engines, Unity3D; Interactive design with 3D models in VR. Students will learn to work with a key aspect of virtual reality, i.e., creating user interaction with the digital world. The course will cover the basic principles of creating interaction with virtual reality, taking into account the natural movements of the human body. In the end, students will receive useful advice from experts in the field of XR, and the main task to consolidate the result will be the creation of their own project where a person interacts with virtual reality; Creation of interactive 3D characters and dialogues. Students will learn to create communication between users of virtual reality, in particular the psychology of communication in VR, the basic principles of animation of 3D characters, in particular, game characters that will be used by the player and NPCs that will interact with a real player; Creating the First VR Game is the final course of the curriculum from the University of London, in which students have to create their first game in virtual reality and learn all the main stages of its development: idea, storyboarding, prototyping, testing, and implementation. The hosts of the Virtual Reality Development Specialization program are Professor Marco Gillies and Dr. Sylvia Xueni Pan. Gillies is an Academic Director of Distance Learning and Deputy Head of Computing at the University of London. Pan is a senior lecturer at the Virtual Reality department of the same university. You can sign up for the course here: https://www.coursera.org/specializations/virtual-reality  Extended Reality for Everybody by Michigan University  A learning program from the University of Michigan that introduces students to the general concept of extended reality. Its total duration is 3 months, 7 hours a week. The main goal of the program is to teach students the basic concepts of XR, the key problems of the development of augmented reality, and to correct them in further work with programs, as well as to learn how to create their own programs. The program consists of three main courses: Introduction to VR/AR/MR/XR, Technologies, Applications, and Key Issues. An introductory course to the concept of augmented reality where students will learn to understand the essential difference between virtual, augmented, mixed, and extended reality. Students will also learn more about the current state of XR, its main advantages, level of development, and problems; User experience and VR/AR/MR interaction design. In this course, students will learn the basic principles of creating XR experiences, including creating extended reality prototypes and putting them into operation. In addition, the issue of ethics in creating an interactive XR application for the user will be raised here; XR applications development with WebXR, Unity, and Unreal Engine. Students will gain practical skills in creating VR experiences in WebXR or Unity, AR applications with or without markers. The final course is where students will learn the basic concepts and techniques of creating complex applications in augmented reality, as well as learn to create their own apps taking into account the ethics, privacy,…



Let's discuss your ideas

Contact us