Giter Club home page Giter Club logo

unitychatgpt's Introduction

Unity ChatGPT Experiments

Few examples based on my ๐Ÿค– ChatGPT with Unity video series on YouTube which is now supporting ChatGPT API and ChatGPT Python Wrapper BUT highly experimental.

๐Ÿ”” Support all my work by Subscribing to YouTube thank you !

ChatGPT Demo Scenes

Scenes
ChatGPTLogger.unity: a simple scene showing you how to ask ChatGPT to generate code which creates primitive cubes ChatGPTPlayerClones: loads a player armature from resources, clones players every 1/2 a second, gets the starter assets input component, and makes players move and jump

ChatGPT Example Prompts

  1. A unity c# class script that creates 100 cubes by Using PrimitiveType cubes and then forms a three dimensional pyramid
  2. A unity c# class script that finds a PlayerArmature game object and get StarterAssetsInputs component and sets the "move" field to a vector2 with 0.3f for x and 0 for y, set "move" field to 0 after 3 seconds, then set "jump" field to true for 3 seconds
  3. A unity c# class script that loads a PlayerArmature from Resources consistently every 1/2 second, get StarterAssetsInputs component, set the "move" field to a vector2 with 1.0f for x and 0 for y, then set the "jump" field to true

Unity Requirements:

  1. Unity 2021.3.8f or greater

  2. Roslyn C# - Runtime DLLs which you can get from the Resources folder. I'm also planning to add the Class Library project to GitHub which should allow you to generate these DLLs yourself.

  3. Open any of the available scenes

  4. Create an account in OpenAI

  5. Get a new API Key and your API Organization

  6. Update ChatGPTSettings file located under Assets/Settings/ChatGPT/

  7. Each scene has a ChatGPTTester game object & script in the hierarchy, feel free to associate a new ChatGPTQuestion scriptable object as a reference as shown below:

ChatGPT Flask Service

โš ๏ธDeprecated - the latest changes use ChatGPT API instead of a python wrapper, however you could still use this but the python service may need some refactoring as the incoming object changed**

ChatGPT is not officially available which means there're unofficial solutions which allow you to use code which gets ChatGPT answers from OpenAI by using browser automation tools. To do this do the following:

  1. Open a terminal and cd into this repo UnityChatGPT > Service folder
  2. Be sure you've Python 3.7 or greater installed if not (download it before proceeding)
  3. Create a Python virtual environment and activate it: (note that I am using Windows and some of these commands may differ a bit with macOS or Linux)
    python -m venv chatgpt_env
    cd chatgpt_env
    .\Scripts\activate
    pip install pyreadline3
    pip install git+https://github.com/mmabrouk/chatgpt-wrapper
    playwright install firefox
    pip install flask
    
  4. Login to OpenAI with the following command:
    chatgpt install
    
  5. Now you should have an environment created and ChatGPT tested

How to run the samples ?

  1. Run our ChatGPT flask service which exposes an endpoint at /chatgpt/question/

     python .\chatgpt_service.py
    
  2. Test the ChatGPT flask service by doing a GET request at http://127.0.0.1:5000/chatgpt/status if you get the response below proceed to step 4:

    {
        "status": "ok"
    }
  3. Open the Unity project and scene located at Assets > Scenes > ChatGPTLogger.unity

  4. Go to Assets > Settings > ChatGPTSettings.asset and point the API Url to your ChatGPT flask service URL:

  5. Ask ChatGPT a question as shown by clicking on "ChatGPTTester" game object:

  6. Hit Play In Unity

Sample Questions to Ask ChatGPT

  1. Write unity c# script monoBehavior named CubePlacer provides a method called Apply() which creates 5 primitive cubes 8 meter away from the camera along the z axis and each separated by 2 meters along the x axis and tilt it by 15 degrees on x

unitychatgpt's People

Contributors

dilmerv avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.