Jump to content
  • Advertisement
Sign in to follow this  
ScArL3T

Unity Scripting

This topic is 781 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I've been implementing a 2D game engine, mostly for learning purposes. I got a basic ECS working and I was wondering how can I implement a scripting component, something like Unity does, that would allow the end-user to easily manipulate entities and their behaviours.

Edited by ScArL3T

Share this post


Link to post
Share on other sites
Advertisement

To be more specific, I'm not looking for a binding or a scripting language. I'm looking for a way to make it easy for the end-user to create and manipulate entities. Thank you for those links, the lua one is really useful!

Share this post


Link to post
Share on other sites

...mostly for learning purposes

...I'm looking for a way to make it easy for the end-user to create and manipulate entities.


The second one can be quite complicated. In light of the first, it might be a better idea for you to start learning the basics of integrating a scripting language, as well as all the other things you need to learn. With experience, you might gain some useful insight into the latter one.

The actual integration of a scripting language can be complex. The highest level is a straight-across, 1 for 1 binding of your API. Somebody (I think it was Hodgman) once linked a colorful article about why that might not be the best idea, but I didn't save the link. The gist of it, though, is that languages like Lua are different beasts than C++, and if all you're going to do is a 1 for 1 API binding, you're probably better off just using C++.

To go beyond 1 for 1 binding, though, takes a little bit of engine-specific ingenuity. One engine, I use, Urho3D, implements Lua and AngelScript binding using the 1 for 1 API exposure, but they also integrate a ScriptObject component that can be added to an object. This component acts as a glue layer, passing events across the Lua/C++ or AS/C++ boundary.

Still, I suggest you spend some time playing with things, rather than trying to design something easy to use by end-users right out of the gate.

Share this post


Link to post
Share on other sites

I thought that trying to implement this would be a nice challenge and an interesting feature. Thank you for your reply and I will most definitely not jump straight into it but I'm still looking for an idea.

Share this post


Link to post
Share on other sites

If all you want is your users to be able to change some parameters and don't need a whole programming language, you may consider instead using a plain text data description file format, such as ini, yaml or json. There are lots of parsers available in many languages.

Edited by Daixiwen

Share this post


Link to post
Share on other sites

Scripting is just another word for programming, and "scripting languages" are still just programming languages. So the question is really: In my ECS framework, how can I make a component that the user programs :)

 

Figuring out the what and why of this question in much more detail will be very useful, before you dive into a 2nd programming language as the how.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!