Cursor + Unity: my experience so far...
2023-05-15
AI is part and parcel of web development, but how well does it work in mobile game development?
What is Cursor?
If you're interested in building anything, then AI development tools will been hot on your radar.
Essentially, AI dev tools like Cursor and Windsurf massively streamline the process of going back and forth with ChatGPT, slowly refining code piece by piece. Equally, if you are the beginning of your project they can lay a solid foundation for you to build on.
Auto-Complete
One of Cursor's offerings is an autofill functionality for code, this attempts to autopredict code to save you time. This goes beyond finishing your current line, Cursor can suggest and write entire functions given enough context.
For example, if I have a function called 'InstitutionClick' that is called when an institution upgrade is clicked. This involves several variables of different types in different classes.
If I then decided to start typing 'MasteryUpgr..." Cursor is able to create an entire function, substituting out each institution variable and class for their analagous mastery counterpart.
It is worth mentioning that the auto-complete can be completely wrong, and when it is, it gets in the way of clicking tab to autofill a variable name, which is very counter-productive.
PS: if auto-complete is saving you a lot of time, it may mean you have a code duplication problem!
Composer
The prized feature of cursor is the AI chat interface, able to answer your questions and make direct changes to your code.
Using Cursor removes the struggle of going back and forth with ChatGPT or Claude, and allows you to agree to code changes line by line. This means you catch moments where the AI has misunderstood, or make improvements to their implementation.
Unity gives you no choice but to learn C#, as a beginner it can be easy to miss key functionality that can make your game more robust, and your code more organised. Cursor can tell you when a new class should be defined, and write the entire script defining it.
You quickly find it is much more efficient to work with AI when it is able to see your entire repository, and when it is able to make changes itself. As there are so many interconnected scripts and classes in a unity project, this feature lends itself very nicely.
Conclusion
Cursor is already great, and with the rate of improvement to LLMs these days, it will only get better.
The implementation and UI is smooth, and LLMs already have a solid grasp on C# and game architecture - just don't expect to get too much out of it before the $20 paywall!