Search Unity

Python in unity

Discussion in 'Scripting' started by lorenzoidd, Apr 27, 2018.

  1. lorenzoidd

    lorenzoidd

    Joined:
    Apr 27, 2018
    Posts:
    3
    Hey, is there any way to apply python in unity, I suck in C# and JavaScript but I am really good with python, so is there any way I can use python instead of C# or JavaScript in unity? If there is none, is there a way I can learn either of these two languages?
     
  2. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    there is an asset you can buy: https://assetstore.unity.com/packages/tools/integration/python-interpreter-645
    But I guess you will not be able to do much with it. You can just call some methods of unity. But usually you have to derive from certain classes (mostly MonoBehaviour) to make a game in Unity. So you will probably need to learn a new language.
    My advise: Go for C#. Most unity developers using it and there are a lot of sources for C# in general. JavaScript is actually not really JavaScript. It is a customization called "UnityScript". But with C# you have more power.
    Google is your friend to find tutorials.
     
    mirajira8 and sharma5305 like this.
  3. lorenzoidd

    lorenzoidd

    Joined:
    Apr 27, 2018
    Posts:
    3
    do you know how to code in C#? Because if you do, how did you learn and is there a specific way I can learn it?
     
  4. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    yes, I know and I learned it more than ten years ago with XNA Game Studio 1.0
    I prefer to make a goal for myself (like: I want to make a frogger-like game) and try to find out how I can do it by extensively searching with google.
    However, other people prefer to do some tutorials or reading books before trying things alone.
    It depends what kind of person you are. But in either case: search the internet for help.
     
  5. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,537
    How did you learn python?

    Apply those same learning/training skills to learning C#.
     
    rickblacker likes this.
  6. QuinnWinters

    QuinnWinters

    Joined:
    Dec 31, 2013
    Posts:
    494
    To add to the excellent answers already posted, this is a good starting place: https://unity3d.com/learn/tutorials/s/scripting

    When I learned I read through all that. It didn't do me much good without practical c# experience though. Read it to get a basic grasp of what's going on, then start putting together small projects and when you're stumped on what to do in one of them google it and if google doesn't help ask questions here.

    If you already know python well you have a solid understanding of how coding works. All coding languages work pretty much the same way on a fundamental level. Similarly to how spoken languages are all similar fundamentally yet can be vastly different in form and execution.
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you really want to, you can use Boo, which is similar to Python. You can't create Boo scripts directly in the editor, but you can create them in a text editor and save them in your project, and it works. (Yes, even in Unity 2018.) You'd have to find older Unity docs for info on Boo scripting, like Unity 4.x. Probably not worth learning Unity and wrestling with out of date docs at the same time, but still, it's possible.

    --Eric
     
  8. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Even if you found a ready made package where you could completely replace all C# with python without issue, you're still going to need to go through Unity tutorials, use the Unity scripting reference, and find code examples to be able to learn to do anything in Unity, and all of that is in C#. So you're still going to be stuck.

    Learning C# would probably be a lot easier than blindly trying to learn Unity using a language where nothing is documented.
     
  9. cchpackers1

    cchpackers1

    Joined:
    Mar 15, 2019
    Posts:
    6
    Hello!
    Does any one know how to package together a Unity build with a python script. Such as opening the script from Unity as an executable.
     
  10. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You could include the python script in StreamingAssets, and you could launch the python interpreter with process.start.
     
  11. gilzamir

    gilzamir

    Joined:
    Aug 10, 2018
    Posts:
    1
    There is a simple way with UnityRemote to connect Python Script to Unity engine. See: https://github.com/gilcoder/UnityRemote.
     
  12. Jeff_Blumenthal

    Jeff_Blumenthal

    Joined:
    Apr 7, 2017
    Posts:
    8
  13. Matjio

    Matjio

    Unity Technologies

    Joined:
    Dec 1, 2014
    Posts:
    108
  14. thedandyyy

    thedandyyy

    Joined:
    Mar 24, 2022
    Posts:
    2
    Hi. In 2022 It's possibile write the game logic with python with the Package Python for Unity