Skip to content
← Back to Community
PyUnity: a Python Implementation of the UnityEngine
Profile icon
pyunity

So for the past 6-8 months (with a long hiatus in the middle), I have been working on this library, only just as a bit of fun. This has been a solo project, and I hope that some people can aid me in my journey to completing this and putting it into production.

https://github.com/pyunity/pyunity

https://pypi.org/project/pyunity

https://pyunity.readthedocs.io/

Discord server: https://discord.gg/tc28HfxZw3

If you would like to contribute, drop me an email at [email protected] or DM me on discord (Rayzchen Gaming#0001).

Features

As of now, here are the current features:

  • GameObjects and hierarchy system
  • Quaternions and Vector3 functions (cross, dot, multiplication etc)
  • A basic sound system using PyGame
  • A custom logger
  • 3 different window providers, automatically selecting the most suitable one
  • A basic physics engine (i would like to create my own custom one based on the UnityEngine physics engine using RigidBodies and Colliders)

and much more!

Details

There are many missing features as of now, such as cleaning up library imports and applying textures to meshes, but that is the sole reason I am looking for collaborators. Right now I don't really know how to fix most of the problems I am facing.

Just to clarify, this is nothing to do with C# or using the Engine, it is only to replicate the engine in pure Python. Of course, it will require a significant amount of optimization, but I would like it to be quite lightweight with minimal dependencies. In the future, I would like a system of creating an executable and/or building for mobile apps.

Example

A minimal example is as so:

from pyunity import * scene = SceneManager.AddScene("Scene 1") SceneManager.LoadScene(scene)

Example 1 packaged in the project is a spinning cube. Here is the code:

from pyunity import * class Rotator(Behaviour): def Update(self, dt): self.transform.eulerAngles += Vector3(0, 90, 135) * dt def main(): scene = SceneManager.AddScene("Scene") scene.mainCamera.transform.localPosition = Vector3(0, 0, -10) cube = GameObject("Cube") renderer = cube.AddComponent(MeshRenderer) renderer.mesh = Mesh.cube(2) renderer.mat = Material(Color(255, 0, 0)) cube.AddComponent(Rotator) scene.Add(cube) scene.List() SceneManager.LoadScene(scene) if __name__ == "__main__": main()
Voters
Profile icon
CSharpIsGud
Profile icon
InvisibleOne
Profile icon
ch1ck3n
Profile icon
xfinnbar
Profile icon
pyunity
Comments
hotnewtop
Profile icon
MrVoo

Still doesn't work :(

Profile icon
CSharpIsGud

You know something is good when I upvote it. (I've upvoted less than 5 posts, ever)

Profile icon
InvisibleOne

This looks pretty cool.

Profile icon
ch1ck3n

when i run the exmaple it says behaiviour not defined

Profile icon
ch1ck3n

woah epic