Unity Experiments

JSON as Scripting Language


This is me trying out a scripting language I made based on JSON. The idea was that I wanted to create 'programmable characters' without using a programming language (platforms like iOS have annoying restrictions in this regard), have reusable components, and greatly reduce iteration time in creating a character (via in-game character builder ui). 

Of course, I got a bit carried away.. the images and animations are loaded during runtime. Everything you see as a result of user input is scripted. I also practically remade NCalc at which point I scrapped the code and used NCalc. 

Now one of the weirdest thing is handling state/conditionals. I initially used a sort of state engine in the JSON. Then I decided to use components to avoid conditionals. So if you want the character to be able to move you just add a movement component. If you don't want the character to move then you just remove the movement component. I also had to implement a component stack.. so instead of removing a component you can push and pop components to revert to a previous state.

Overall, it works by mapping events to actions, and breaking everything up into components or groups.

For those who are curious, here is a zip file of the character data: Bandit.zip

Character Folder Structure

Random Misc Experiments


Having fun with Unity's new UI System. You can also see some loading & saving.

Playing with Unity Animations

InControl is a really nice library. I was able to connect any controller during runtime and just 'pop' a character into the game.


No comments:

Post a Comment