Coding in unity with python?

Hello there! So I’ve bean doing bolt on unity for a while now (visual scripting) and kinda wanted to try real scripting.
I know the main language for unity is C# but its to crazy for my little brain. I knew python was a bit easier but wasn’t sure if unity supports it or has a asset to support it.
I saw there’s a way to support it or something similar but wasn’t sure of the limitations on it? Like could I make a 3d fps with python( If its supported )?

AFAIK it’s not yet supported. There was various third party things that did it in the store, but the Unity python support is (as far as I know) only for editor tools, not for actually writing games.

Honestly if you can tackle Python and visual scripting (I saw your other post), you really shouldn’t have any issues with C#… You should just do it. :slight_smile:

Have you tried doing some good coding tutorials? There’s a ton of examples out there and it is a far more reliable type-safe language than Python, so the compiler is able to help you do the right thing much moreso than with Python.

Here’s a handful of coding tutorials… you won’t pick it up in one session but you can keep building on it more and more and more every day you use it.

Imphenzia / imphenzia - super-basic Unity tutorial:

Jason Weimann:

Brackeys super-basic Unity Tutorial series:

Sebastian Lague Intro to Game Development with Unity and C#:

Tutorials and example code are great, but keep this in mind to maximize your success and minimize your frustration:

How to do tutorials properly, two (2) simple steps to success:

Tutorials are a GREAT idea. Tutorials should be used this way:

Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That’s how software engineering works. Every step must be taken, every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly, literally NOTHING can be omitted or skipped.

Fortunately this is the easiest part to get right: Be a robot. Don’t make any mistakes.
BE PERFECT IN EVERYTHING YOU DO HERE!!

If you get any errors, learn how to read the error code and fix your error. Google is your friend here. Do NOT continue until you fix your error. Your error will probably be somewhere near the parenthesis numbers (line and character position) in the file. It is almost CERTAINLY your typo causing the error, so look again and fix it.

Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost. If you want to learn, you MUST do Step 2.

Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there’s an error, you will NEVER be the first guy to find it.

Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!

Thanks for the help. I haven’t actually done python, just heard it was a easier then C#. Ya I’ll probably just do it. Just wanted to check before. It’s a bit scary diving into c# being the only true language I’ve done is a smidge of Lua. Thanks for the support.

Technically speaking you can compile python to CIL with such things as ironpython. And there is something called pysharp which is supposed to do something similar in Unity (didn’t research it deeply).

BUT, it’s not like this has a supported simple pipeline for Unity, and rather instead would require lots of jumping through hoops… and if your attempt is to get an easier language… well, I’d argue the complexities would be above the bar of entry for C#.

Anyways… C# is a pretty easy language as well. Especially in terms of how Unity works.

Python is easy for simple imperative scripts. But it gets complicated when you start implementing object-oriented concepts. And well in Unity… object-oriented concepts are a must (i.e. you do a lot of inheriting from MonoBehaviour to attach scripts to GameObjects).

So yeah… while in theory it’s doable. In practice C# is way simpler to use in Unity.

…

In the end though, and this is my strong bias. Python is one of those “easy to pick up, hard to master” languages. Personally I’m not a huge fan of those sorts of languages. They’re great for small little scripts, a giant pain to scale.

Thanks alot man! This motivated me to do C# and it’s super similar to bolt. And that 1st tutorial you gave me helped so much.

Indeed… there’s only so many common operations you do on a computer, and as far as Unity is concerned, there’s only X number of different conversations you can have with it through code.

Language stuff you learn will fall into these broad three “buckets” of knowledge:

  • C# language syntax (organization, structure, grammar, punctuation)
  • the .NET API (all the tools that come with C#: lists, dictionaries, file IO, etc)
  • the Unity API (everything in the using UnityEngine; namespace)

Thanks to google and example code you can always go searching for answers pretty successfully.