

We have one more step before we can start coding the script that will make all this work. This will appear like a frantic but discernible running motion. This will allow for 12 frames per second of animation. In the Animation window, change the Samples value to 12. Your Animation window should now look like this image. Now drag them from the Project tab into the Animation tab. In the Project tab shift-left–click each of the frames of animation to select them all. Your Animation window should now look like this image.Ĭlick the Create button and name the new animation Walk. Now, find the Animation tab that you opened at the start of the project and click on it. Next, make sure the Player object is selected in the Hierarchy tab. Select the Project tab and notice that the appearance of the player asset has changed slightly as shown next.Ĭlick the little triangle icon shown in the previous image and then you can see each of the frames of animation that we sliced up previously. Now drag the player sprite from the Project tab to the Sprite field of the Sprite Renderer component. Make sure to click the Apply button at the top-right of the Sprite Editor tab.In the next image, you can just about see the lines representing the results of the slice operation.īefore we create the actual animation, Select the Player object in the Hierarchy tab and then in the Inspector tab select Add Component | Rendering | Sprite Renderer. Click the Slice button and Unity will slice the sprite-sheet into five individual frames of animation. The default options just mentioned are fine for slicing up Bob. That is why there are a number of options to choose from. Some sprite-sheets have their images organized in different ways. I docked mine alongside the Projects tab as shown in the next image.Ĭlick the Slice drop-down that is highlighted in the previous image and check that the options Automatic, Centre, and Delete Existing are chosen. You might find it useful to drag the tab of the Sprite Editor window and dock it.

Slicing the sprite-sheetĪgain in the Inspector window, click the Sprite Editor button. Now Unity knows treat player.png as a sprite sheet with multiple frames of animation. Click the Apply button in the Inspector tab. In the Inspector window change the Sprite mode option from Single to Multiple. Browse to the player.png image you just downloaded and click the Import button. Right-click in the project tab and select Import New Asset…. This isn’t necessary to complete the tutorial. Note that in the image at the top of the page I have added a pretty background.
Gamemaker studio 2 import sprite sheet code#
However, if you are kind enough to help spread the word about this tutorial, there is a nice little download that contains the code and the graphics in one handy zip file.ĭownload this sprite-sheet which contains all the frames of animation for a simple walking animation. For this tutorial, it is convenient to disable this behavior.Īll the code and graphics that you need for this project are contained on this page.
Gamemaker studio 2 import sprite sheet full#
In a full game, we would almost certainly leave gravity enabled and provide a level for the player to jump and fall around in. In the RigidBody 2D component set the Gravity Scale to zero and check the Freeze Rotation option. So we can eventually move the character add a RigidBody 2D component as well. Be sure to choose Animator and not Animation. Make sure the Player object is selected in the Hierarchy tab and click the Add Component button in the Inspector tab. Right-click in the Hierarchy tab and select Create Empty…. Creating a game object and adding an Animator componentīefore we move on to the animation proper, we need a game object in the scene. It doesn’t really matter where these tabs are added because they will work anywhere and you can easily re-size them to accomadate whatever you are doing. We will see the difference between these simmilarly named tabs as we proceed.

Now select Window | Animator to open an Animator tab. In the main menu select Window | Animation to open an Animation tab. Before we get started adding our sprite-sheet to the project, we will need some animation-specific tabs open in the Unity editor. Name your project Sprite-sheet animation, select the 2D option and click the Create Project button.
