Search Unity

Many teachers around the world struggle with delivering introductory workshops on making games. Tools like Unity are complex pieces of software and offer a wide range of possibilities. However, the Unity editor also assumes that the students know many concepts that are hard to deliver in just a few lessons.

One of my first “missions” as Technical Evangelist at Unity was to present a 2-day workshop to young kids in a town near Brighton. The attendees were boys and girls aged 11-16, who didn’t know Unity before but had received some lessons in basic programming. The easiest way to introduce them to Unity would be a step-by-step tutorial. But after the first day I decided that this approach wouldn’t allow them to express the creativity I saw they had right away. So on the train back I started working on a small framework that would allow them to build a variety of games, fast, and without necessarily knowing about programming.

The “Playground Project” was born.

Needs and solutions

When I set off to create the framework, I had a few goals in mind. First, I wanted to teach kids that making games can be fun. I wanted to give them the full game creation experience, but at the same time trying not to overwhelm them with the technical concerns that come with it. Most importantly, I didn’t want to constrain their creativity.

I also decided it would be cool to allow them to play with the parameters of the game, to allow some sort of game tuning and playtesting (future game designers, yes!).

Another key goal was to minimise my intervention as teacher, since I quickly discovered that handling a class of 25 alone was impossible. The framework would need to prevent as many mistakes as possible, and guide the kids.

So I came up with a small framework that revolves around a few cornerstones around which I make every decision:

  • A set of one-task Components that are easy to use and mix
  • Extremely simple scene setup
  • Physics-based gameplay = more fun!
  • 2D for simplicity (and the kids can import other graphics from the web)
  • Custom Inspectors to perform error detection in the setup
  • Pre-made UI to visualise health and score

Going into more detail, the Components are all simple scripts that perform mostly one task, so they can be mixed to produce more refined gameplay. For instance, you can use together the scripts RotateWithArrows and PushWithButton to create a character that rotates with the Left/Right keys and move forward with the Up key, such as a spaceship or a car seen from above.

Their inspectors are heavily customised with the help of Editor code and provide plenty of guidance in setting up. This component for example shows some tips at the bottom, and will hide the option Look axis if the Orient to direction boolean is unselected.

play1

User Interface

Talking about the UI, I made it a prefab that can be dropped into the scene without any setup. It will accommodate different kinds of gameplay, and will change depending if the game is for one or two players. This is its Inspector:

play2

And this is how it looks in-game:

play3

Additionally, it will automatically display a small inventory in the bottom-left corner for games that have objects that can be picked up. In this example, the player has 0 coins and 1 key:

play4

Conditions, Actions, Attributes

After the first iteration proposed in the original workshop, I tried to give some structure to the Playground Project, so I came up with some key groups of scripts that try to serve specific classes of problems.

At the heart of the framework are the Conditions, which are basically if statements made components. They check for a specific condition and, if this is verified, execute some actions. The Condition scripts available for now are Area Conditions (basically triggers, enter, exit, and stay), the Collision Condition (fires on collision), and a configurable Key Condition to capture input. More may be added in the future.

In the first iteration, I grouped the actions under an UnityEvent. Despite its power though, the UnityEvent block in the Inspector is huge and complicated to setup, because it exposes ALL the public properties and methods of the target objects:

play5

So, I decided to implement a series of mini-scripts that contain one action. Conditions now have a simplified block (made with the useful ReorderableList, check it out on Valentin’s blog!) where you can connect them easily by drag-and-drop. I grouped these scripts under the name Gameplay Actions, and they all implement the IGameplayAction interface.

Following this simplification, a ConditionKeyPress Inspector with the Gameplay Actions block looks like this:

play6

The bool Use custom actions reveals another UnityEvent block to allow the most fearless students to get the full power of UnityEvents and access any variable or method.

Finally, some scripts are grouped under Attributes, as they effectively work as if they were mere properties of an object. For instance, adding a Resource Attribute to an gameObject makes it an object that can be picked up and stacked, shown in the UI as an icon or amount, and later on consumed by a ConsumeResource GameplayAction script.

Example games

The Scenes folder contains some example games, intended to showcase the variety of gameplay that can be achieved with the framework.

The Defender game shows how to shoot objects (the laser) or generate them randomly (the asteroids), and is also an example of a life-based game where the player’s health script is not on the character gameObject, but on a part of the environment.

play7
The Football game is a 2-player football game that shows how to use ConditionCollision scripts to setup goals, and reset players and ball position when the players score a goal.

play8

The Maze game shows the use of Collectables (for the coins), how to setup Area Conditions, and load another level through the LoadLevelAction.

play9

The Lander game showcases an atypical setup for collisions, where only collisions with certain parts of the spacecraft will make it explode.

play10

Finally, the Roguelike game shows how to create a small “crafting” system with Conditions and ConsumeResource actions. The merchant asks for three coins (which have a Resource script), and once you collect them, he will give the player a key (another Resource) which can be picked up to open the door.

play11

I advise to remove the example games before distributing the framework to the kids, to avoid them copying them. We said this framework was made to make their imagination go wild, right?

Try the framework!

Together with the rest of the evangelism team at Unity we have decided to release the framework on Github. You can clone the repository, modify it in any way, and use it in your workshops. It comes with a small Wiki, which hopefully will clear all doubts on how to use it.

I’m still working on the framework, trying to balance the addition of new scripts and possibilities while still keeping the whole thing accessible and understandable (for the kids, and for the teacher who have to explain it!), while keeping the documentation up to date with the changes.

Keep in mind that the project is maintained only by me, so for suggestions, doubts or (hopefully not) bugs you can ping me on Twitter.

16 Comments

Subscribe to comments

Comments are closed.

  1. Can i use this on a game i am makeing for xbox one

  2. You can always tell an expert! Thanks for cogrbitutinn.

  3. It would be a neat challenge for a game jam for pros to demo how far you can go with just these simple scripts

    1. Ciro Continisio

      October 3, 2016 at 3:23 pm

      That’s a very cool idea :)
      It would also put grown-ups and kids on the same level (more or less)

  4. it is soo cool

  5. When I saw this post I was amazed because I’ve got an “events and actions” system on my roadmap for my game, and you’ve basically gone ahead and done 80% my vision right there!!

    I see it’s released under MIT licence. Licencing gets confusing. Am I correct in thinking that I can use the work and include it in my commercial project as long as I include the copyright notice together with a link to the source?

    It’s not like to have to therefore opensource my own project right? And the licence I include is relevant to the bits of code that I used, not my entire project?

    Thanks.

    1. Ciro Continisio

      October 3, 2016 at 3:25 pm

      Yes, you just need to include the MIT License and there’s no need to open source your whole project. However, I’d advice against using this framework for a commercial project. It’s generally built more for being practical to use for newbies, and not optimised for performance.

      Your call :)

  6. Nice project and good to learn from. =)

  7. This sounds much like GameMaker ‘s D&D system , look there to find more inspiration if you haven’t.

    And guys, Ok visual scripting is nice but clumsy text based coding is required to make any big project and everyone doesn’t feel that it is the case. A hardcore programmer finds the graphs clumsy and less readable and might call it a mess unless node count is less than 20

  8. Great idea.

    Now, if only there was some type of, let’s say, “visual scripting” system that supported custom blocks you could give to beginners. Har dee har har.

  9. Cool, but this just highlights how primitive and clumsy text coding is. Please don’t abandon the Hack Week XI node scripting prototype that was developed. https://www.youtube.com/watch?v=2VPHhTyHv2s&index=5&list=PLX2vGYjWbI0SMX0_qC5nwfF5-VStdCw2w
    It could be the perfect combination of snapped Scratch style vertical code and free-form node placement for variables and calculations. Add in visible code running (flashing nodes/wires) + full keyboard usability (eg a cursor + pressing enter to shift nodes down) and it’ll be great. Especially as it wrote C# in the background.
    I’ve been teaching games programming for 10 years and it’s mostly the terrible text based IDE’s fault that puts off beginners. Yes, even Visual Studio is primitive. Somewhere between text and full freeform node editors would be the sweet spot I think.

    1. Maybe that sweet spot already exists. It’s called GameFlow, it’s a non node-based visual scripting tool and it’s basically like this PlayGround Project but on steroids: You have events, actions, (multiple) conditions, variables, parameters, lists, commands, macros, timers and a lot more to play with. If you feel curious, the tool is available on the Asset Store at a very affordable price.

      1. Oh wow, this GameFlow is exactly that, thanks for the suggestion!

        To be fair though, when you add features you also add complexity. My project is unfortunately limited, but it’s also easier to digest, and it’s meant to be just an intermediate step towards full-fledged programming (or working with programmers on the design side).

        1. I think your project is perfect for the purpose that you made it. I agree with you and I can see here a really good job in balancing features vs complexity, a task which is not easy at all specially when your users are young kids. I know about it, because that has been a recurrent problem in GameFlow since its inception. So, I can’t recommend this project enough: For me It is a fantastic first step for kids and newbies to quickly learn the basics of Unity and how important is to have the right tools to unleash their creativity.

      2. Seconded on the GameFlow suggestion. It is nice because it is no additional editor, just adding attributes.

        It is as deep as a you want to use it. And it is very useful for really simple stuff

        After a timer plays, activate something; once something is activated, move it to something, etc. If an object enters this trigger volume, instantiate something . Very simple things that can be powerful

  10. Triforce FTW