0
\$\begingroup\$

I want to create a game in Unity or UE4 which allows the user to write scripts in Python and run them mainly to control the AI. I will have to find a way to enable runtime script execution first. After searching the internet i was able to find some ways that may work.
What i cant find an answer for is how to limit the parts of engine and game code the user has access to so that the player doesnt feel like he's playing it in God mode.
And the main question is that even if i am able to restrict access to the API will it violate the terms of agreement for these commercial engines because the player will get access to the underlying engine and will be manipulating objects within it. I don't intend to make a moddable game just a game that requires you to write some code but that would be an extreme case to think about.

\$\endgroup\$
2
1
\$\begingroup\$

If you're using the Unity engine and add AI scripting support with Python, that doesn't inherently give players "access to the underlying engine". The only way you'd be giving "access to the underlying engine" is if you made a Python wrapper that could access substantial portions of the Unity API, which would be a nightmare to implement. AI scripting does not inherently need such a wrapper.

However, as Vaillancourt noted in his comment, Lua is most likely a better choice for scripting that can be modified by end-users.

\$\endgroup\$
4
  • \$\begingroup\$ Wouldn't i need the Unity API for AI scripting? For example what if a user wants to get enemy positions? If i was using a python wrapper it would probably call GameObject.FindObjectsByType<Enemy>().gameObject.transform? \$\endgroup\$
    – spatial
    Apr 30 at 18:54
  • \$\begingroup\$ Unless you made a gigantic nightmare wrapper, you wouldn't be calling those individual Unity functions from Python. Depending on the code structure you use, your Python code might ask Unity for an array of enemy positions, or Unity might supply Python with an array of enemy positions each frame. You should cache the list of enemies rather than calling FindObjectsOfType<>() repeatedly. \$\endgroup\$
    – Kevin
    Apr 30 at 19:29
  • \$\begingroup\$ No amount of exposing the runtime API would give users access to the editor API - they wouldn't be able to compile new game executables for example. So you wouldn't be duplicating the functionality of "The Unity Software" (the editor suite). \$\endgroup\$
    – DMGregory
    Apr 30 at 22:36
  • \$\begingroup\$ @DMGregory I was addressing his assertion that he'd be giving "access to the underlying engine". He didn't specifically mention the Editor, and obviously it wouldn't be possible to access Editor APIs in a player build. I have never published a Unity game with end-user modding or scripting support and don't know Unity's legal specifics in this area off the top of my head. \$\endgroup\$
    – Kevin
    Apr 30 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.