In this article, I will show you how to make a game object move in five minutes or less using the PlayMaker add-on for Unity, with no code.
Creating a Unity Game With PlayMaker
If you haven’talready, head over to the Unity website and download the latest version of Unity. Unity is a free, user-friendlygame engine that allows developers and studios to create 3D games for Android, iOS, Windows, and over 20 other platforms.
What exactly is PlayMaker? PlayMaker is a paid add-on for Unity that allows you to create games without having to code. Created byHutong Games, PlayMaker uses functional state machines (FSM) to add physics, animation, interactive objects and scene changes easily. Their developers have already created the scripts for you, which can significantly cut your game development time in half. As of writing this tutorial, the current price is $65.00, with over 370 five-star reviews.
Once you have Unity, create a new 3D project. I made a simple scene with a terrain and a sphere. In the main viewport, under the menu toolbar, you will find the Asset Store tab. Type PlayMaker into your search box. Follow the instructions to place your purchase. You may need to use the link in your confirmation email or import it directly through Unity. You may find that it takes you back to the asset store, but don’t worry—click Add to Cart and it should give you the download option.
Download the file and unzip it into a folder you can easily find. Now let’simport a custom package by going to Assets > Custom Package and opening your unzippedPlayMaker file.
After you’ve imported the package, choose Install PlayMaker. This will add the PlayMaker option in your menu bar.
Every FSM needs to be attached to an object. In this case, our spherewill be the object we are looking to control. Later, we will need to specify our game object once an action is created. For now, let’s confirm our sphere has a rigid body.In addition, let’sfreeze theX and Y positionof oursphere intheInspector window.
The PlayMaker Editor
Go to the PlayMaker tab on your top menu bar and click PlayMaker editor. This will open the below window. Click and drag the tab to place it next to your Game tab on the bottom.
On the right of the editor window, you will see four tabs:
This is where you will choose the options and parameters for your state. Along with changing the name, you can add in your own description, which comes in handy when you have large projects. For example, this state will move the ball left.
To add a state machine to an object, choose your object in theHierarchy. Head over to theEditorwindow and right click to add anFSM. This begins the state machine, and this willbestateone.
Second, we need to create aSystemEvent(what happens after user interaction). This is what will set offthestate,for example button clicked ormouse over.For this project, we will choosemouse over.
Let’s create our next state and name itBall Moves. You will immediately see ared exclamation point; this is because once you create a state, you will have to define a transition. To define atransitionfromone stateto the other, right-click and chooseTransition Target. There you will see the name of the second state you created.You will now see an arrow connecting your two states.
It’s time to add physics to our object. The way we do this is by activating the Action Browser. There are numerous actions you can choose for your object, which is pretty cool.
Feel free to look around at all of the commands you can use in your project. For every action, we will need to set up parameters.
In order to make our sphere move, we will need to give it force and velocity through the Action Browser. First, make sure the proper state is chosen. To search for an action, type it in the search box. Let’s search for add force. Under the State tabto the right, change the Y variable to 100.
Now let’s add velocitybyrepeating the steps above. Change the Y variable to50.
Hit play and voila! Your sphere should move towards the camera. There are almost an unlimited amount of actions you can perform simply with PlayMaker once you understand the interface.
In my opinion, PlayMaker is a great addition to Unity. Even if you do have coding experience, it can make it that much easier to create interactive, fully animated games in half the time.
Unity has an active economy. There are many other products that help you build out your project. The nature of the platform also makes it a great option from which you can better your skills. Whatever the case, you can see what we have available in the ThemeKeeper Market.
If you are a beginner, once you learn the interface you can vastly improve your learning curve. PlayMakeralso has a very active community, where you can find questions and answers from users.