Let's begin by adding the avatar, which will symbolize the player in the game, in game development parlance. The actor that represents the player in-game is generally referred to by the acronym PC (Player Character). Having established this, we will use this abbreviation from time to time henceforth. Perform the following steps for adding our first actor:
Cowboy
:One of the first things that we'll need to do, now that we've created the shell of our Actor Type, is import a few animations so that the actor has a visual representation within the game. Perform the following steps:
Game
Assets/Graphics/Actor Animations/cowboy down.png
.Having completed the preceding steps, you should now be able to see the selected graphic appear in the Import Frames from Image Strip window, as shown in the following screenshot:
Clearly, this animation contains four horizontal frames. Hence, before clicking on Add, we must perform the following steps:
4
.Down
, as shown in the following screenshot:The other fields, Looping, Synchronized, and Origin Point are ideally configured by default in this case, so we need not change them. We have two more animations to import for this Actor. On the left-hand side of the screen, at the bottom of the Animations pane, you will see a number of buttons, as shown in the following screenshot:
The names of these buttons appear on the screen when you hover the mouse cursor over them. These are, from left to right, as follows:
Now let's click on the Create Animation button to add our second animation. You will see, as shown in the following screenshot, that there are now two animations in our Animations pane. The new animation is called Animation 1 and is still blank, as we have not yet imported the frame sheet. Change the Name to Left
, and select the Click here to add a frame. button, as shown at the bottom center of the following screenshot:
The Import Frames from Image Strip window will open once again. Perform the following steps:
4
.Game AssetsGraphicsActor Animationscowboy left.png
.If you have followed the steps correctly, you should see something like the following screenshot:
If this is not what you see, click on the Remove Animation button (alternatively, you can select the Left animation in the Animations pane, and press Delete on your keyboard), and repeat the aforementioned steps carefully so that you can achieve the desired result.
We have one more animation to import for this actor. Let's follow all the same steps as follows:
Right
.4x
, and Columns to 4
.Game Assets/Graphics/Actor Animations/cowboy right.png
.As mentioned earlier, if you have followed the steps correctly, you should see three functional animations looping in the Animations pane at this point (the animations are subtle, but if you take a look at them closely, you should see them looping), as shown in the following screenshot:
You will notice that one of the animations (Down) has a star on it. This indicates that it is the default animation. If any or all of these animations are not looping, make sure that you have checked the Looping checkbox for each individual animation (it is usually checked by default), as shown in the following screenshot:
Each animation has its own collision shape, so it's important to take a little time to configure this properly. We'll start by selecting the Down animation from the Animations pane, then switching to the Collision context. Take a look at the options shown in the following screenshot:
You will see that, by default, your actor has a collision box, which encompasses the entirety of the graphic, as shown in the following screenshot:
While we do want to use a box-shaped collision for this particular animation, we must customize its position and its dimensions to fit a certain area of the graphic. At the top right of the screen, you will see a pane called Current Shape.
Take a look at the following screenshot:
Let's alter the following values to better suit this animation:
18
.68
.34
.90
.You should now be able to see the updated collision shape to fit the desired collision area on our Animation preview:
Excellent work! You have successfully configured the collision settings for your first animation. Let's get started with the other two animations. In the Animation pane on the left-hand side of the screen, switch to the Left animation. You will see a box collision shape, which encompasses the entire graphic, as before. This time, you must perform the following steps:
We are going to add a polygonal collision shape to this animation. Click on the Add Polygon button shown in the following screenshot:
The Create a Polygon… window will appear on the screen as shown in the following screenshot:
This polygon has only three points by default. We need four to create the intended shape, so let's add an extra point. Click on the Add Point button at the top-left section of the window (it looks like a plus symbol). You should see an additional point appear in the preview on the right-hand side of the window. Finally, let's move the points around to create the shape, as shown in the following screenshot, simply by clicking-and-dragging them around in the preview. The goal here is to approximate the visual area of the log (be aware that the concave collision shapes are prohibited and will not be accepted), as shown in the following screenshot:
When you have succeeded in creating this shape, click on OK to commit and add this shape to the animation. Now, we must create the inverse shape for the Right animation:
Congratulations! You've successfully added both the basic and advanced collision shapes to your animations! Now, we just need to finalize some of the Physics settings for this Actor Type. Switch to the Physics context, as shown in the following screenshot:
Under the General settings, you will see the following options:
Take a look at the following screenshot that shows the options shown in the General settings:
Well done! You've successfully configured all of the fundamental settings for the Cowboy actor! This Actor Type now has useable animations and is capable of detecting and reacting to the physical interactions within our game levels using Collision shapes!
We must add one more actor to our game, which will be easy now that we've learned the process, before moving on to the next chapter, where we'll begin by writing Behaviors to make our actors do things in-game. This time, we'll add an obstacle in the form of a falling rock. Perform the following steps:
Rock
and then click on Create.Game AssetsGraphicsActor Animationslarge rock.png
. Set Columns and Rows to 1
, Resize Method to Bicubic, and then click on Add.Default
.4
, Y Position (Top) to 0
, and Radius to 16
. Then, click on OK to commit this collision shape to the animation, as shown in the following screenshot:Cracked
.Game AssetsGraphicsActor Animationslarge rock cracked.png
. Click on Add.Exploding
.Game AssetsGraphicsActor Animationslarge rock exploding.png
. Set Columns to 3
, then click on Add.What you will now see in the Animations pane should be an Actor Type with three animations, which is similar to the one shown in the following screenshot:
Finally, let's switch our editing context from Appearance to Physics in the top menu:
Then, perform the following steps:
30
.60
, as shown in the following screenshot:3.129.26.108